Skip to content

Commit

Permalink
#228 Created VRow.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich2 committed Mar 22, 2023
1 parent 8f3f961 commit c553e75
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 59 deletions.
2 changes: 1 addition & 1 deletion EGrid/src/eg320/Terr320E0.scala
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ object Terr320E0 extends Long320Terrs

res
}

val help = new WTerrSetter(grid, terrs, sTerrs, corners)
{ override val rowDatas: RArr[TRow] = RArr(
//TRow
Expand All @@ -102,7 +103,6 @@ object Terr320E0 extends Long320Terrs
)
}
help.run

}

object BritReg
Expand Down
56 changes: 21 additions & 35 deletions EGrid/src/eg320/Terr320E30.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ object Terr320E30 extends Long320Terrs
def gs(r: Int, cStart: Int, tileValues: Multiple[WTile]*): Unit = { res.setRowEnd(r, cStart, tileValues :_*); () }
def wr(r: Int, tileValues: Multiple[WTile]*): Unit = { res.setRow(r, tileValues :_*); () }

wr(156, Head2Land(5, Hilly, Tundra), Head2Land(0, Hilly, Tundra), sea)
wr(154, taigaHills, taiga * 2, tundra)
wr(152, taiga, taiga, taiga, taiga)
wr(150, taiga, taiga * 3)
wr(148, taiga * 2, taiga * 3)
wr(146, plain, taiga * 4)
wr(144, plain * 5)
Expand All @@ -34,12 +30,8 @@ object Terr320E30 extends Long320Terrs
override val sTerrs: HSideLayer[WSide] =
{ val res: HSideLayer[WSide] = grid.newSideLayer[WSide](WSideNone)

res.setSomeInts(WSideLt(), 157,1533, 157,1537, 156,1538)//North Norway
res.setSomeInts(WSideRt(), 156,1530, 157,1531, 157,1535)//North Norway

res.setSomeInts(WSideMid(), 151,1539, 152,1538, 153,1537, 153,1539, 153,1541, 153,1543, 154,1544, 155,1543)
res.setSomeInts(WSideMid(Lake), 149, 1537)
res.setSomeInts(WSideMid(), 145,1527, 146,1528, 147,1529, 147,1531, 147,1533, 148,1530, 149,1531, 150,1532, 151,1533, 152,1534)//Baltic
//res.setSomeInts(WSideMid(Lake), 149,1537)
res.setSomeInts(WSideMid(), 145,1527, 146,1528, 147,1529, 147,1531, 147,1533)//Baltic
res.setSomeInts(WSideMid(), 131, 1527, 133,1525, 134,1524, 135,1523, 136,1522, 136,1542, 137,1541, 137,1543)
res.setSomeInts(WSideMid(), 130,1524, 131,1525, 132,1526, 132,1530)
res.setSomeInts(WSideMid(), 133,1531, 133,1533, 133,1535)//Bosphorus
Expand All @@ -53,37 +45,17 @@ object Terr320E30 extends Long320Terrs
override val corners: HCornerLayer =
{ val res = grid.newHVertOffsetLayer

res.set2CornersIn(156, 1532, 5, 7)//North Norway
res.set2CornersIn(156, 1536, 0, 7)//North Norway

res.setMouth2(154, 1534)//White Sea north West
res.setVert3In(154, 1542)//White Sea
res.setVert0In(152, 1540)//White Sea
res.setCorner(152, 1544, 0, HVDR)//White Sea
res.setCorner(154, 1542, 2, HVUL)//White Sea
res.setCorner(154, 1542, 1, HVDL)//White Sea
res.setCorner(154, 1542, 0, HVDL)//White Sea
res.setTJunction(153, 1538)//White Sea
res.setVert4In(152, 1540)//White Sea
res.setMouth5(150, 1542)//White Sea

res.setMouth2(150, 1534)//Lake Ladoga north west
res.setMouth5(148, 1540)//Leke Ladoga south east
// res.setMouth5(148, 1540)//Leke Ladoga south east

//res.setMouth5Corner(144, 1528)
res.setCorner(144, 1528, 5, HVDn)//Baltic west
res.setCorner(144, 1528, 0, HVDR)//Baltic west
res.setCorner(146, 1530, 4, HVDR)//Baltic
res.setCorner(146, 1530, 5, HVDR)//Baltic
res.setCorner(148, 1528, 3, HVUL)//Baltic
//res.setCorner(148, 1528, 3, HVUL)//Baltic
res.setTJunction(147, 1530)//Baltic - Gulf of Finland - Gulf of Bothnia
res.setVert3In(148, 1532)//Helsinki - Tallinn
res.setMouth4(148, 1536)//St Petersburg
res.setVert5In(148, 1532)//Gulf of Bothnia
res.setVert2In(150, 1532)//Gulf of Bothnia
res.setVert5In(150, 1534)//Gulf of Bothnia
res.setVert2In(152, 1532)//Gulf of Bothnia
res.setMouth3(154, 1534)//Gulf of Bothnia north
//res.setVert3In(148, 1532)//Helsinki - Tallinn
//res.setMouth4(148, 1536)//St Petersburg
//res.setVert5In(148, 1532)//Gulf of Bothnia

res.setMouth0(134, 1542)//Kerch straits

Expand Down Expand Up @@ -111,4 +83,18 @@ object Terr320E30 extends Long320Terrs

res
}

val help = new WTerrSetter(grid, terrs, sTerrs, corners)
{
override val rowDatas: RArr[RowBase] = RArr(
TRow(156, Head2Land(5, Hilly, Tundra), Head2Land(0, Hilly, Tundra), sea),
TRow(154, taigaHills, taiga * 2, Head4Land(0, Plains, Tundra)),
VRow(153, MouthDn(1534)),
TRow(152, Head1Land(2, Plains, Taiga), taiga, sea, taiga),
VRow(151, VertInDR(1532)),
TRow(150, Head1Land(2, Plains, Taiga), taiga * 3),
)
}

help.run
}
68 changes: 45 additions & 23 deletions EGrid/src/egrid/WTerrSetter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,56 @@ import prid._, phex._
abstract class WTerrSetter(gridIn: HGrid, val terrs: HCenLayer[WTile], val sTerrs: HSideLayer[WSide], val corners: HCornerLayer)
{
implicit val grid: HGrid = gridIn
case class TRow(row: Int, mutlis: Multiple[WTile]*)
sealed trait RowBase
case class TRow(row: Int, mutlis: Multiple[WTile]*) extends RowBase
case class VRow(row: Int, edits: VRowElem*) extends RowBase

val rowDatas: RArr[TRow]
//var c: Int = 0
def run: Unit = rowDatas.foreach{data =>
val row = data.row
var c = grid.rowLeftCenC(row)
data.mutlis.foreach { multi =>
multi.foreach { tile =>
if (c > grid.rowRightCenC(row)) excep("Too many tiles for row.")
terrs.set(row, c, tile)
tile match
{ case ct: Coastal =>
{ corners.setNCornersIn(row, c, ct.numIndentedVerts, ct.indentStartIndex, 7)
ct.indentedSideIndexForeach{ i =>
val side = HCen(row, c).side(i)
side match {
case _: WSideMid =>
case _: WSideLt if i >= 3 => sTerrs.set(side, WSideBoth(ct.sideTerrs))
case _ if i >= 3 => sTerrs.set(side, WSideRt(ct.sideTerrs))
case _: WSideRt => sTerrs.set(side, WSideBoth(ct.sideTerrs))
case _ => sTerrs.set(side, WSideLt(ct.sideTerrs))
sealed trait VRowElem
case class MouthDn(c: Int) extends VRowElem
case class VertInDR(c: Int, WSTerr: WSTerr = Sea) extends VRowElem

val rowDatas: RArr[RowBase]

def run: Unit = rowDatas.foreach{
case data: TRow =>
{ val row = data.row
var c = grid.rowLeftCenC(row)
data.mutlis.foreach { multi =>
multi.foreach { tile =>
if (c > grid.rowRightCenC(row)) excep("Too many tiles for row.")
terrs.set(row, c, tile)
tile match {
case ct: Coastal => {
corners.setNCornersIn(row, c, ct.numIndentedVerts, ct.indentStartIndex, 7)
ct.indentedSideIndexForeach { i =>
val side = HCen(row, c).side(i)
sTerrs(side) match {
case _: WSideMid =>
case _: WSideLt if i >= 3 => sTerrs.set(side, WSideBoth(ct.sideTerrs))
case _ if i >= 3 => sTerrs.set(side, WSideRt(ct.sideTerrs))
case _: WSideRt => sTerrs.set(side, WSideBoth(ct.sideTerrs))
case _ => sTerrs.set(side, WSideLt(ct.sideTerrs))
}
}
}
case _ =>
}
case _ =>
c += 4
}
}
}
case data: VRow =>
{ val row = data.row
data.edits.foreach{
case MouthDn (c) =>
{ corners.setMouth3 (row + 1, c)
sTerrs.set(row - 1, c, WSideMid())
}
case VertInDR(c, st) =>{
corners.setVert5In(row - 1, c + 2)
sTerrs.set(row, c + 1, WSideMid(st))
sTerrs.set(row - 1, c, WSideMid(st))
}
c += 4
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions Tiling/srcHex/HSideAny.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ trait HSideLayerAny[A]
unsafeArray(i) = value
}

def set(r: Int, c: Int, value: A)(implicit grid: HGridSys, ct: ClassTag[A]): Unit = {
val i = grid.sideLayerArrayIndex(r, c)
if (i >= unsafeArray.length) deb(s"$r, $c")
unsafeArray(i) = value
}

def set(grid: HGridSys, hs: HSide, value: A)(implicit ct: ClassTag[A]): Unit =
{ val i = grid.sideLayerArrayIndex(hs)
if (i >= unsafeArray.length) deb(s"$hs")
Expand Down

0 comments on commit c553e75

Please sign in to comment.