예제 #1
0
func (p *Power) next(root *graph, visited map[node]bool, dx, dy int, t tile.Type) {
	coord := layout.C(root.X+dx, root.Y+dy)
	tiles := p.l.Get(coord)
	for _, tt := range tiles {
		d, ok := p.l.TileSet.Get(tt).(Def)
		if !ok {
			continue
		}
		if t2 := tt.Type(p.l.TileSet); t.Equal(t2) || t2.Equal(t) {
			n := node{coord, tt}
			if visited[n] {
				return
			}
			visited[n] = true

			g := &graph{
				node: n,
				emit: d.PowerGenerated(p.l.TileSet),
				used: d.PowerUsage(p.l.TileSet),
			}
			root.neighbors = append(root.neighbors, g)
			p.visit(g, visited)
			return
		}
	}
}
예제 #2
0
func (p *Power) get(x, y int, t tile.Tile) bool {
	return p.powered[node{layout.C(x, y), t}]
}