minor renaming

This commit is contained in:
Josh Deprez 2021-09-13 16:50:35 +10:00
parent 49b08f278c
commit d59577fc77
12 changed files with 47 additions and 46 deletions

View file

@ -23,7 +23,7 @@ func init() {
// Billboard draws an image at a position. // Billboard draws an image at a position.
type Billboard struct { type Billboard struct {
ID ID
Hidden Hides
Pos image.Point Pos image.Point
Src ImageRef Src ImageRef
ZPosition ZPosition

View file

@ -30,7 +30,7 @@ func init() {
// DebugToast debugprints a string for a while, then disappears. // DebugToast debugprints a string for a while, then disappears.
type DebugToast struct { type DebugToast struct {
ID ID
Hidden Hides
Pos image.Point Pos image.Point
Timer int // ticks Timer int // ticks
Text string Text string
@ -47,11 +47,11 @@ func (DebugToast) DrawBefore(Drawer) bool { return false }
func (d *DebugToast) Toast(text string) { func (d *DebugToast) Toast(text string) {
d.Text = text d.Text = text
d.Timer = 120 d.Timer = 120
d.Hidden = false d.Hides = false
} }
func (d *DebugToast) Update() error { func (d *DebugToast) Update() error {
if d.Hidden = d.Timer <= 0; !d.Hidden { if d.Hides = d.Timer <= 0; !d.Hides {
d.Timer-- d.Timer--
} }
return nil return nil
@ -59,7 +59,7 @@ func (d *DebugToast) Update() error {
// PerfDisplay debugprints CurrentTPS and CurrentFPS in the top left. // PerfDisplay debugprints CurrentTPS and CurrentFPS in the top left.
type PerfDisplay struct { type PerfDisplay struct {
Hidden Hides
} }
func (p PerfDisplay) Draw(screen *ebiten.Image, _ *ebiten.DrawImageOptions) { func (p PerfDisplay) Draw(screen *ebiten.Image, _ *ebiten.DrawImageOptions) {

View file

@ -24,7 +24,7 @@ func init() {
type Fill struct { type Fill struct {
ID ID
Color color.Color Color color.Color
Hidden Hides
ZPosition ZPosition
} }

View file

@ -37,8 +37,8 @@ func init() {
// component must be the designated root component - usually a scene of some // component must be the designated root component - usually a scene of some
// kind. // kind.
type Game struct { type Game struct {
Disabled Disables
Hidden Hides
ScreenSize image.Point ScreenSize image.Point
Root interface{} // typically a *Scene or SceneRef though Root interface{} // typically a *Scene or SceneRef though
Projection geom.IntProjection Projection geom.IntProjection
@ -53,7 +53,7 @@ type Game struct {
// Draw draws everything. // Draw draws everything.
func (g *Game) Draw(screen *ebiten.Image) { func (g *Game) Draw(screen *ebiten.Image) {
if g.Hidden { if g.Hidden() {
return return
} }
@ -71,7 +71,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
// Draw everything in g.drawList, where not hidden (itself or any parent) // Draw everything in g.drawList, where not hidden (itself or any parent)
for _, d := range g.drawList.list { for _, d := range g.drawList.list {
// Is d hidden itself? // Is d hidden itself?
if h, ok := d.(Hider); ok && h.IsHidden() { if h, ok := d.(Hider); ok && h.Hidden() {
accum[d] = state{hidden: true} accum[d] = state{hidden: true}
continue // skip drawing continue // skip drawing
} }
@ -91,7 +91,7 @@ func (g *Game) Draw(screen *ebiten.Image) {
p := stack[l1] p := stack[l1]
stack = stack[:l1] stack = stack[:l1]
if h, ok := p.(Hider); ok { if h, ok := p.(Hider); ok {
st.hidden = st.hidden || h.IsHidden() st.hidden = st.hidden || h.Hidden()
} }
if st.hidden { if st.hidden {
accum[p] = state{hidden: true} accum[p] = state{hidden: true}
@ -119,7 +119,7 @@ func (g *Game) Layout(outsideWidth, outsideHeight int) (w, h int) {
// Update updates everything. // Update updates everything.
func (g *Game) Update() error { func (g *Game) Update() error {
if g.Disabled { if g.Disabled() {
return nil return nil
} }
@ -139,7 +139,7 @@ func (g *Game) Update() error {
} }
// Is u disabled itself? // Is u disabled itself?
if d, ok := u.(Disabler); ok && d.IsDisabled() { if d, ok := u.(Disabler); ok && d.Disabled() {
accum[u] = true accum[u] = true
continue continue
} }
@ -160,7 +160,7 @@ func (g *Game) Update() error {
p := stack[l1] p := stack[l1]
stack = stack[:l1] stack = stack[:l1]
if d, ok := p.(Disabler); ok { if d, ok := p.(Disabler); ok {
st = st || d.IsDisabled() st = st || d.Disabled()
} }
accum[p] = st accum[p] = st
} }
@ -179,9 +179,10 @@ func (g *Game) Update() error {
sort.Stable(g.drawList) sort.Stable(g.drawList)
// Truncate tombstones from the end. // Truncate tombstones from the end.
for i := g.drawList.Len() - 1; i >= 0; i-- { for i := g.drawList.Len() - 1; i >= 0; i-- {
if g.drawList.list[i] == (tombstone{}) { if g.drawList.list[i] != (tombstone{}) {
g.drawList.list = g.drawList.list[:i] break
} }
g.drawList.list = g.drawList.list[:i]
} }
return nil return nil
} }

View file

@ -62,7 +62,7 @@ type Collider interface {
// Disabler components can be disabled. // Disabler components can be disabled.
type Disabler interface { type Disabler interface {
IsDisabled() bool Disabled() bool
Disable() Disable()
Enable() Enable()
} }
@ -78,7 +78,7 @@ type Drawer interface {
// Hider components can be hidden. // Hider components can be hidden.
type Hider interface { type Hider interface {
IsHidden() bool Hidden() bool
Hide() Hide()
Show() Show()
} }

View file

@ -16,29 +16,29 @@ type Bounds image.Rectangle
// BoundingRect returns b as an image.Rectangle. // BoundingRect returns b as an image.Rectangle.
func (b Bounds) BoundingRect() image.Rectangle { return image.Rectangle(b) } func (b Bounds) BoundingRect() image.Rectangle { return image.Rectangle(b) }
// Disabled implements Disabler directly (as a bool). // Disables implements Disabler directly (as a bool).
type Disabled bool type Disables bool
// IsHidden returns h as a bool. // Disabled returns d as a bool.
func (d Disabled) IsDisabled() bool { return bool(d) } func (d Disables) Disabled() bool { return bool(d) }
// Disable sets d to true.
func (d *Disables) Disable() { *d = true }
// Enable sets d to false.
func (d *Disables) Enable() { *d = false }
// Hides implements Hider directly (as a bool).
type Hides bool
// Hidden returns h as a bool.
func (h Hides) Hidden() bool { return bool(h) }
// Hide sets h to true. // Hide sets h to true.
func (d *Disabled) Disable() { *d = true } func (h *Hides) Hide() { *h = true }
// Show sets h to false. // Show sets h to false.
func (d *Disabled) Enable() { *d = false } func (h *Hides) Show() { *h = false }
// Hidden implements Hider directly (as a bool).
type Hidden bool
// IsHidden returns h as a bool.
func (h Hidden) IsHidden() bool { return bool(h) }
// Hide sets h to true.
func (h *Hidden) Hide() { *h = true }
// Show sets h to false.
func (h *Hidden) Show() { *h = false }
// ZPosition implements DrawAfter and DrawBefore using only Z information. // ZPosition implements DrawAfter and DrawBefore using only Z information.
type ZPosition int type ZPosition int

View file

@ -34,8 +34,8 @@ func init() {
// PrismMap is a generalised 3D tilemap/wallmap/etc. // PrismMap is a generalised 3D tilemap/wallmap/etc.
type PrismMap struct { type PrismMap struct {
ID ID
Disabled Disables
Hidden Hides
Ersatz bool Ersatz bool
Map map[geom.Int3]*Prism // pos -> prism Map map[geom.Int3]*Prism // pos -> prism
DrawOffset image.Point // offset applies to whole map DrawOffset image.Point // offset applies to whole map

View file

@ -34,8 +34,8 @@ type Scene struct {
ID ID
Bounds // world coordinates Bounds // world coordinates
Components []interface{} Components []interface{}
Disabled Disables
Hidden Hides
} }
// Scan returns all immediate subcomponents (including the camera, if not nil). // Scan returns all immediate subcomponents (including the camera, if not nil).

View file

@ -25,7 +25,7 @@ func init() {
type Sprite struct { type Sprite struct {
Actor Actor Actor Actor
DrawOffset image.Point DrawOffset image.Point
Hidden Hides
Sheet Sheet Sheet Sheet
anim *Anim anim *Anim

View file

@ -38,8 +38,8 @@ func init() {
// Tilemap renders a grid of rectangular tiles at equal Z position. // Tilemap renders a grid of rectangular tiles at equal Z position.
type Tilemap struct { type Tilemap struct {
ID ID
Disabled Disables
Hidden Hides
Map map[image.Point]Tile // tilespace coordinate -> tile Map map[image.Point]Tile // tilespace coordinate -> tile
Ersatz bool // disables collisions ("fake wall") Ersatz bool // disables collisions ("fake wall")
Offset image.Point // world coordinates Offset image.Point // world coordinates

View file

@ -89,8 +89,8 @@ func (w *Wall) Transform() (opts ebiten.DrawImageOptions) {
// WallUnit is a unit in a wall. Unlike a tile in a tilemap, WallUnit is // WallUnit is a unit in a wall. Unlike a tile in a tilemap, WallUnit is
// responsible for drawing itself. // responsible for drawing itself.
type WallUnit struct { type WallUnit struct {
Disabled Disables
Hidden Hides
Tile Tile // chooses which cell in wall.Sheet to draw Tile Tile // chooses which cell in wall.Sheet to draw
ZPosition ZPosition

View file

@ -25,7 +25,7 @@ func init() {
// Awakeman is a bit of a god object for now... // Awakeman is a bit of a god object for now...
type Awakeman struct { type Awakeman struct {
engine.Disabled engine.Disables
Sprite engine.Sprite Sprite engine.Sprite
CameraID string CameraID string
ToastID string ToastID string