Line data Source code
1 : package mapplanner
2 :
3 : import (
4 : gc "github.com/kijimaD/ruins/internal/components"
5 : "github.com/kijimaD/ruins/internal/consts"
6 : )
7 :
8 : // RoomDraw は部屋を描画するビルダー
9 : type RoomDraw struct {
10 : FloorTile string
11 : }
12 :
13 : // PlanMeta はメタデータをビルドする
14 : func (b RoomDraw) PlanMeta(planData *MetaPlan) error {
15 1 : b.build(planData)
16 1 : return nil
17 1 : }
18 :
19 : func (b RoomDraw) build(planData *MetaPlan) {
20 1 : for _, room := range planData.Rooms {
21 1 : b.rectangle(planData, room)
22 1 : }
23 : }
24 :
25 : func (b RoomDraw) rectangle(planData *MetaPlan, room gc.Rect) {
26 1 : for x := room.Min.X; x <= room.Max.X; x++ {
27 1 : for y := room.Min.Y; y <= room.Max.Y; y++ {
28 1 : idx := planData.Level.CoordToIndex(consts.Coord[consts.Tile]{X: x, Y: y})
29 1 : if isValidTileIdx(planData, idx) {
30 1 : planData.Tiles[idx] = planData.GetTile(b.FloorTile)
31 1 : }
32 : }
33 : }
34 : }
|