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.
type Billboard struct {
ID
Hidden
Hides
Pos image.Point
Src ImageRef
ZPosition

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -38,8 +38,8 @@ func init() {
// Tilemap renders a grid of rectangular tiles at equal Z position.
type Tilemap struct {
ID
Disabled
Hidden
Disables
Hides
Map map[image.Point]Tile // tilespace coordinate -> tile
Ersatz bool // disables collisions ("fake wall")
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
// responsible for drawing itself.
type WallUnit struct {
Disabled
Hidden
Disables
Hides
Tile Tile // chooses which cell in wall.Sheet to draw
ZPosition

View file

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