/// <summary> /// 此函数负责对比当前显示计划与计划表的差异,对比结果通知主线程 /// </summary> private void initPlan() { //GridPlan.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //GridPlan.Columns[5].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //GridPlan.Columns[6].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; //GridPlan.Columns[8].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter; string plineid = LoginInfo.ProductLineInfo.RMES_ID; ///得到当前显示的计划集 string sql = "SELECT plan_seq,product_model,plan_code,plan_so,plan_qty,online_qty,offline_qty,customer_name,begin_date,end_date,create_time,remark " + " FROM data_plan Where run_flag='Y' and confirm_flag='Y' and pline_code='" + PlineCode + "' AND to_char(end_date,'yyyymmdd')>=to_char(to_date('" + LoginInfo.WorkDate + "','yyyy-mm-dd'),'yyyymmdd') AND to_char(begin_date,'yyyymmdd')<=to_char(to_date('" + LoginInfo.WorkDate + "','yyyy-mm-dd'),'yyyymmdd') order by begin_date,plan_seq "; DataTable dt = dataConn.GetTable(sql); GridPlan.DataSource = dt; GridPlan.ClearSelection(); //List<PlanEntity> currentPlanSet = GridPlan.DataSource as List<PlanEntity>; //List<PlanEntity> oraclePlanSet = PlanFactory.GetByPlineCode(PlineCode); ////如果当前计划集与数据库计划集不同则刷新计划,如果相同则跳过 //if (currentPlanSet != null) //{ // if (!currentPlanSet.Equals(oraclePlanSet)) // getPlan(PlineCode); //} //else { getPlan(PlineCode); } }
public override void ApplyToPath(IRandom rand, GridPlan floorPlan) { for (int ii = 0; ii < floorPlan.RoomCount; ii++) { GridRoomPlan plan = floorPlan.GetRoomPlan(ii); if (!BaseRoomFilter.PassesAllFilters(plan, this.Filters)) { continue; } if (plan.RoomGen is IPermissiveRoomGen) { plan.PreferHall = true; } } }
private bool roomViable(GridPlan floorPlan, int xx, int yy) { //must be PRESENT, SINGLE and immutable GridRoomPlan plan = floorPlan.GetRoomPlan(new Loc(xx, yy)); if (plan == null) { return(false); } if (plan.Bounds.Area > 1) { return(false); } if (!BaseRoomFilter.PassesAllFilters(plan, this.Filters)) { return(false); } return(true); }
private void initPlan() { GridPlan.Columns[0].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; GridPlan.Columns[1].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; GridPlan.Columns[2].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; GridPlan.Columns[3].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; GridPlan.Columns[4].DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft; string plineid = LoginInfo.ProductLineInfo.RMES_ID; GridPlan.DataSource = null; ///得到当前显示的计划集 string sql = "select rmes_id,plan_code,plan_so,product_model,complete_qty,pline_code,station_code,team_code,shift_code,user_id,work_date,start_time,plan_qty,customer_name from data_complete_statistics t where work_date=to_date('" + LoginInfo.WorkDate + "','yyyy-mm-dd') and shift_code='" + ShiftCode + "' and team_code='" + Team_Code + "' and station_code='" + StationCode + "' order by plan_code desc "; DataTable dt = dataConn.GetTable(sql); if (dt.Rows.Count == 0) { GridPlan.DataSource = null; return; } ; GridPlan.DataSource = dt; GridPlan.ClearSelection(); GridPlan.Rows[0].Selected = true; }
private bool spaceViable(GridPlan floorPlan, Rect rect) { //all tiles must be ABSENT, or SINGLE AND not immutable for (int xx = rect.Start.X; xx < rect.End.X; xx++) { for (int yy = rect.Start.Y; yy < rect.End.Y; yy++) { GridRoomPlan plan = floorPlan.GetRoomPlan(new Loc(xx, yy)); if (plan == null) { continue; } if (plan.Bounds.Area > 1) { return(false); } if (!BaseRoomFilter.PassesAllFilters(plan, this.Filters)) { return(false); } } } return(true); }
private void getPlan(string plinecode) { //按序显示当前站点的可执行计划 //List<PlanEntity> ds1 = PlanFactory.GetByPlineID(plineid); //修改为按生产线和班组取当日计划并排序: List <PlanEntity> ds2 = PlanFactory.GetByPlineCode(plinecode); if (ds2 != null && ds2.Count < 1) { return; } List <PlanEntity> ds1 = (from p in ds2 where p.RUN_FLAG == "Y" orderby p.BEGIN_DATE ascending, p.PLAN_SEQ ascending select p).ToList <PlanEntity>(); if (ds1.Count == 0) { GridPlan.DataSource = null; return; } List <PlanEntity> ds3 = ds1.GetRange(0, ds1.Count); foreach (PlanEntity s in ds3) { int complete_qty = ProductCompleteFactory.GetCompleteQtyByPlanStation(CompanyCode, PlineCode, s.PLAN_CODE, StationCode); if (complete_qty >= s.PLAN_QTY) { ds1.Remove(s); } //if (!TheProcessValid(s.PLAN_CODE)) ds1.Remove(s); } if (ds1.Count == 0) { GridPlan.DataSource = null; return; } ; PrevPlanNum = ds1.Count; GridPlan.DataSource = ds1; GridPlan.ClearSelection(); GridPlan.Rows[0].Selected = true; PlanEntity en1 = ds1[0]; string plan_code = en1.PLAN_CODE; InitPlan(plan_code); for (int i = 0; i < GridPlan.Rows.Count; i++) { //如果完工标识为Y则黄色 string runFlag = GridPlan.Rows[i].Cells["colrunflag"].Value.ToString(); //if (runFlag == "F") //{ // for (int j = 0; j < GridPlan.Columns.Count; j++) // GridPlan.Rows[i].Cells[j].Style.BackColor = Color.Yellow; //} //如果完工标识为Y,实际上线数量>0则绿色 int realOnlineQuantity = Convert.ToInt32(GridPlan.Rows[i].Cells["ColRealOnlineQuantity"].Value.ToString()); if (realOnlineQuantity > 0 && runFlag == "Y") { for (int j = 0; j < GridPlan.Columns.Count; j++) { GridPlan.Rows[i].Cells[j].Style.BackColor = Color.Green; } } //挂起 if (runFlag == "G") { for (int j = 0; j < GridPlan.Columns.Count; j++) { GridPlan.Rows[i].Cells[j].Style.BackColor = Color.Red; } } } }
public void InitGrid(GridPlan plan) { this.GridPlan = plan; }
public void InitGrid(GridPlan plan) { GridPlan = plan; }
public static ConsoleKey PrintGridRoomHalls(IGenContext map, string msg, bool printDebug, bool printViewer) { IRoomGridGenContext context = map as IRoomGridGenContext; if (context == null) { return(ConsoleKey.Enter); } StringBuilder str = new StringBuilder(); GridPlan plan = context.GridPlan; if (plan == null) { return(ConsoleKey.Enter); } for (int yy = 0; yy < plan.GridHeight; yy++) { if (yy > 0) { str.Append('\n'); } for (int xx = 0; xx < plan.GridWidth; xx++) { int roomIndex = plan.GetRoomIndex(new Loc(xx, yy)); if (roomIndex == -1) { str.Append('0'); } else// if (roomIndex < 26) { str.Append((char)('A' + roomIndex % 26)); } //else // str.Append('@'); if (xx < plan.GridWidth - 1) { if (plan.GetHall(new LocRay4(xx, yy, Dir4.Right)) != null) { str.Append('#'); } else { str.Append('.'); } } } if (yy < plan.GridHeight - 1) { str.Append('\n'); for (int xx = 0; xx < plan.GridWidth; xx++) { if (plan.GetHall(new LocRay4(xx, yy, Dir4.Down)) != null) { str.Append('#'); } else { str.Append('.'); } if (xx < plan.GridWidth - 1) { str.Append(' '); } } } } string newStr = str.ToString(); if (gridDebugString[currentDepth].MapString == newStr) { return(ConsoleKey.Enter); } gridDebugString[currentDepth].MapString = newStr; if (printDebug) { Debug.WriteLine(msg); Debug.Print(newStr); } if (printViewer) { SteppingIn = false; Console.Clear(); Console.WriteLine(msg); Loc start = new Loc(Console.CursorLeft, Console.CursorTop); Console.Write(newStr); Loc end = new Loc(Console.CursorLeft, Console.CursorTop + 1); Console.SetCursorPosition(start.X, start.Y); int prevFarthestPrint = end.Y; while (true) { int farthestPrint = end.Y; Loc gridLoc = new Loc(Console.CursorLeft, Console.CursorTop) - start; Loc mapLoc = gridLoc / 2; rewriteLine(farthestPrint, String.Format("X:{0:0.0} Y:{1:0.0}", ((float)gridLoc.X / 2), ((float)gridLoc.Y / 2))); farthestPrint++; bool alignX = gridLoc.X % 2 == 0; bool alignY = gridLoc.Y % 2 == 0; if (alignX && alignY) { int index = plan.GetRoomIndex(mapLoc); GridRoomPlan roomPlan = plan.GetRoomPlan(mapLoc); if (roomPlan != null) { string roomString = String.Format("Room #{0}: {1}", index, roomPlan.RoomGen.ToString()); if (roomPlan.PreferHall) { roomString += " [Hall]"; } rewriteLine(farthestPrint, roomString); farthestPrint++; string componentString = String.Format("Components: {0}", String.Join(", ", roomPlan.Components)); rewriteLine(farthestPrint, componentString); farthestPrint++; } } else if (alignX) { GridHallPlan hall = plan.GetHall(new LocRay4(mapLoc, Dir4.Down)); if (hall != null) { rewriteLine(farthestPrint, "Hall: " + hall.RoomGen.ToString()); farthestPrint++; string componentString = String.Format("Components: {0}", String.Join(", ", hall.Components)); rewriteLine(farthestPrint, componentString); farthestPrint++; } } else if (alignY) { GridHallPlan hall = plan.GetHall(new LocRay4(mapLoc, Dir4.Right)); if (hall != null) { rewriteLine(farthestPrint, "Hall: " + hall.RoomGen.ToString()); farthestPrint++; } } for (int ii = farthestPrint; ii < prevFarthestPrint; ii++) { clearLine(ii); } prevFarthestPrint = farthestPrint; Console.SetCursorPosition(start.X + gridLoc.X, start.Y + gridLoc.Y); ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key == ConsoleKey.UpArrow) { Console.SetCursorPosition(Console.CursorLeft, Math.Max(start.Y, Console.CursorTop - 1)); } else if (key.Key == ConsoleKey.DownArrow) { Console.SetCursorPosition(Console.CursorLeft, Math.Min(Console.CursorTop + 1, end.Y - 1)); } else if (key.Key == ConsoleKey.LeftArrow) { Console.SetCursorPosition(Math.Max(start.X, Console.CursorLeft - 1), Console.CursorTop); } else if (key.Key == ConsoleKey.RightArrow) { Console.SetCursorPosition(Math.Min(Console.CursorLeft + 1, end.X - 1), Console.CursorTop); } else { return(key.Key); } } } else { return(ConsoleKey.Enter); } }
public override void ApplyToPath(IRandom rand, GridPlan floorPlan) { int chosenBigRooms = RoomAmount.Pick(rand); for (int ii = 0; ii < chosenBigRooms; ii++) { for (int jj = 0; jj < 20; jj++) { LargeRoom <T> chosenRoom = GiantRooms.Pick(rand); Rect destRect = new Rect(new Loc(rand.Next(floorPlan.GridWidth - chosenRoom.Size.X), rand.Next(floorPlan.GridHeight - chosenRoom.Size.Y)), chosenRoom.Size); if (spaceViable(floorPlan, destRect)) { List <LocRay4> raysOut = new List <LocRay4>(); for (int xx = destRect.Start.X; xx < destRect.End.X; xx++) { LocRay4 locUp = new LocRay4(xx, destRect.Start.Y, Dir4.Up); if (destRect.Start.Y > 0 && floorPlan.GetHall(locUp) != null) { raysOut.Add(locUp); } LocRay4 locDown = new LocRay4(xx, destRect.Start.Y + chosenRoom.Size.Y - 1, Dir4.Down); if (destRect.Start.Y < floorPlan.GridHeight - 1 && floorPlan.GetHall(locDown) != null) { raysOut.Add(locDown); } } for (int yy = destRect.Start.Y; yy < destRect.End.Y; yy++) { LocRay4 locLeft = new LocRay4(destRect.Start.X, yy, Dir4.Left); if (destRect.Start.X > 0 && floorPlan.GetHall(locLeft) != null) { raysOut.Add(locLeft); } LocRay4 locRight = new LocRay4(destRect.Start.X + chosenRoom.Size.X - 1, yy, Dir4.Right); if (destRect.Start.X < floorPlan.GridWidth - 1 && floorPlan.GetHall(locRight) != null) { raysOut.Add(locRight); } } List <List <LocRay4> > exitSets = findHallSets(floorPlan, destRect, raysOut); //exits: no more than allowed if (exitSets.Count > chosenRoom.AllowedEntrances) { continue; } //this block tallies all sets that can be joined to the big room //it also chooses which ones to keep by randomly removing them from the raysOut list int setsTaken = 0; foreach (List <LocRay4> set in exitSets) { List <LocRay4> possibleRays = new List <LocRay4>(); foreach (LocRay4 ray in set) { int scalar = (ray.Loc - destRect.Start).GetScalar(ray.Dir.ToAxis().Orth()); if (chosenRoom.OpenBorders[(int)ray.Dir][scalar]) { possibleRays.Add(ray); } } if (possibleRays.Count > 0) { LocRay4 locRay = possibleRays[rand.Next(possibleRays.Count)]; raysOut.Remove(locRay); setsTaken++; } else { break; } } if (setsTaken == exitSets.Count) { for (int xx = 0; xx < chosenRoom.Size.X; xx++) { for (int yy = 0; yy < chosenRoom.Size.Y; yy++) { //erase rooms in vicinity Loc loc = new Loc(xx + destRect.Start.X, yy + destRect.Start.Y); //erase halls in vicinity floorPlan.EraseRoom(loc); if (xx > 0) { floorPlan.SetHall(new LocRay4(loc, Dir4.Left), null, new ComponentCollection()); } if (yy > 0) { floorPlan.SetHall(new LocRay4(loc, Dir4.Up), null, new ComponentCollection()); } } } //remove all halls still in the list foreach (LocRay4 rayOut in raysOut) { floorPlan.SetHall(rayOut, null, new ComponentCollection()); } //add room floorPlan.AddRoom(destRect, chosenRoom.Gen, new ComponentCollection()); break; } } } } }
private List <List <LocRay4> > findHallSets(GridPlan floorPlan, Rect rect, List <LocRay4> raysOut) { bool[] raysCovered = new bool[raysOut.Count]; List <List <LocRay4> > resultList = new List <List <LocRay4> >(); Graph.GetAdjacents <int> getAdj = (int nodeIndex) => { List <int> returnList = new List <int>(); Loc loc = new Loc(nodeIndex % floorPlan.GridWidth, nodeIndex / floorPlan.GridWidth); int roomIndex = floorPlan.GetRoomIndex(loc); for (int dd = 0; dd < DirExt.DIR4_COUNT; dd++) { Dir4 dir = (Dir4)dd; Loc destLoc = loc + dir.GetLoc(); //check against outside floor bound if (!Collision.InBounds(floorPlan.GridWidth, floorPlan.GridHeight, destLoc)) { continue; } //check against inside rect bound if (Collision.InBounds(rect, destLoc)) { continue; } //check against a valid room int destRoom = floorPlan.GetRoomIndex(destLoc); if (destRoom == roomIndex) { returnList.Add(destLoc.Y * floorPlan.GridWidth + destLoc.X); } else if (destRoom > -1) { if (floorPlan.GetHall(new LocRay4(loc, dir)) != null) { returnList.Add(destLoc.Y * floorPlan.GridWidth + destLoc.X); } } } return(returnList); }; //group the exits together for (int ii = 0; ii < raysOut.Count; ii++) { if (raysCovered[ii]) { continue; } Loc startLoc = raysOut[ii].Traverse(1); List <LocRay4> set = new List <LocRay4>(); Graph.TraverseBreadthFirst(startLoc.Y * floorPlan.GridWidth + startLoc.X, (int nodeIndex, int distance) => { Loc fillLoc = new Loc(nodeIndex % floorPlan.GridWidth, nodeIndex / floorPlan.GridWidth); for (int nn = 0; nn < raysOut.Count; nn++) { if (raysOut[nn].Traverse(1) == fillLoc) { set.Add(raysOut[nn]); raysCovered[nn] = true; } } }, getAdj); resultList.Add(set); } return(resultList); }
public static ConsoleKey PrintGridRoomHalls(IGenContext map, string msg, bool printDebug, bool printViewer) { if (!(map is IRoomGridGenContext context)) { return(ConsoleKey.Enter); } var str = new StringBuilder(); GridPlan plan = context.GridPlan; if (plan == null) { return(ConsoleKey.Enter); } for (int yy = 0; yy < plan.GridHeight; yy++) { if (yy > 0) { str.Append('\n'); } for (int xx = 0; xx < plan.GridWidth; xx++) { int roomIndex = plan.GetRoomIndex(new Loc(xx, yy)); if (roomIndex == -1) { str.Append('0'); } else // if (roomIndex < 26) { str.Append((char)('A' + (roomIndex % 26))); } /* else * str.Append('@'); */ if (xx < plan.GridWidth - 1) { if (plan.GetHall(new LocRay4(xx, yy, Dir4.Right)) != null) { str.Append('#'); } else { str.Append('.'); } } } if (yy < plan.GridHeight - 1) { str.Append('\n'); for (int xx = 0; xx < plan.GridWidth; xx++) { if (plan.GetHall(new LocRay4(xx, yy, Dir4.Down)) != null) { str.Append('#'); } else { str.Append('.'); } if (xx < plan.GridWidth - 1) { str.Append(' '); } } } } string newStr = str.ToString(); if (gridDebugString[currentDepth].MapString == newStr) { return(ConsoleKey.Enter); } gridDebugString[currentDepth].MapString = newStr; if (printDebug) { Debug.WriteLine(msg); Debug.Print(newStr); } if (printViewer) { SteppingIn = false; Console.Clear(); Console.WriteLine(msg); Loc start = new Loc(Console.CursorLeft, Console.CursorTop); Console.Write(newStr); Loc end = new Loc(Console.CursorLeft, Console.CursorTop + 1); Console.SetCursorPosition(start.X, start.Y); int prevFarthestPrint = end.Y; while (true) { int farthestPrint = end.Y; Loc gridLoc = new Loc(Console.CursorLeft, Console.CursorTop) - start; Loc mapLoc = gridLoc / 2; RewriteLine(farthestPrint, $"X:{gridLoc.X / 2f:0.0} Y:{gridLoc.Y / 2f:0.0}"); farthestPrint++; bool alignX = gridLoc.X % 2 == 0; bool alignY = gridLoc.Y % 2 == 0; if (alignX && alignY) { int index = plan.GetRoomIndex(mapLoc); GridRoomPlan roomPlan = plan.GetRoomPlan(mapLoc); if (roomPlan != null) { string roomString = $"Room #{index}: {roomPlan.RoomGen}"; if (roomPlan.Immutable) { roomString += " [Immutable]"; } if (roomPlan.PreferHall) { roomString += " [Hall]"; } RewriteLine(farthestPrint, roomString); farthestPrint++; } } else if (alignX) { IPermissiveRoomGen hall = plan.GetHall(new LocRay4(mapLoc, Dir4.Down)); if (hall != null) { RewriteLine(farthestPrint, "Hall: " + hall); farthestPrint++; } } else if (alignY) { IPermissiveRoomGen hall = plan.GetHall(new LocRay4(mapLoc, Dir4.Right)); if (hall != null) { RewriteLine(farthestPrint, "Hall: " + hall); farthestPrint++; } } for (int ii = farthestPrint; ii < prevFarthestPrint; ii++) { ClearLine(ii); } prevFarthestPrint = farthestPrint; Console.SetCursorPosition(start.X + gridLoc.X, start.Y + gridLoc.Y); ConsoleKeyInfo key = Console.ReadKey(true); if (key.Key == ConsoleKey.UpArrow) { Console.SetCursorPosition(Console.CursorLeft, Math.Max(start.Y, Console.CursorTop - 1)); } else if (key.Key == ConsoleKey.DownArrow) { Console.SetCursorPosition(Console.CursorLeft, Math.Min(Console.CursorTop + 1, end.Y - 1)); } else if (key.Key == ConsoleKey.LeftArrow) { Console.SetCursorPosition(Math.Max(start.X, Console.CursorLeft - 1), Console.CursorTop); } else if (key.Key == ConsoleKey.RightArrow) { Console.SetCursorPosition(Math.Min(Console.CursorLeft + 1, end.X - 1), Console.CursorTop); } else { return(key.Key); } } } else { return(ConsoleKey.Enter); } }
public override void ApplyToPath(IRandom rand, GridPlan floorPlan) { for (int xx = 0; xx < floorPlan.GridWidth - 1; xx++) { for (int yy = 0; yy < floorPlan.GridHeight - 1; yy++) { //check for room presence in all rooms (must be SINGLE and immutable) if (!roomViable(floorPlan, xx, yy)) { continue; } if (!roomViable(floorPlan, xx, yy + 1)) { continue; } if (!roomViable(floorPlan, xx + 1, yy)) { continue; } if (!roomViable(floorPlan, xx + 1, yy + 1)) { continue; } //check for hall connectivity in all constituent halls if (floorPlan.GetHall(new LocRay4(xx, yy, Dir4.Down)) == null) { continue; } if (floorPlan.GetHall(new LocRay4(xx, yy, Dir4.Right)) == null) { continue; } if (floorPlan.GetHall(new LocRay4(xx + 1, yy, Dir4.Down)) == null) { continue; } if (floorPlan.GetHall(new LocRay4(xx, yy + 1, Dir4.Right)) == null) { continue; } if (rand.Next(100) < CombineChance) { //erase the constituent rooms floorPlan.EraseRoom(new Loc(xx, yy)); floorPlan.EraseRoom(new Loc(xx + 1, yy)); floorPlan.EraseRoom(new Loc(xx, yy + 1)); floorPlan.EraseRoom(new Loc(xx + 1, yy + 1)); //erase the constituent halls floorPlan.SetHall(new LocRay4(xx, yy, Dir4.Down), null, new ComponentCollection()); floorPlan.SetHall(new LocRay4(xx, yy, Dir4.Right), null, new ComponentCollection()); floorPlan.SetHall(new LocRay4(xx + 1, yy, Dir4.Down), null, new ComponentCollection()); floorPlan.SetHall(new LocRay4(xx, yy + 1, Dir4.Right), null, new ComponentCollection()); //place the room RoomGen <T> gen = GiantRooms.Pick(rand); floorPlan.AddRoom(new Rect(xx, yy, 2, 2), gen.Copy(), this.RoomComponents.Clone(), false); } } } }
public override void ApplyToPath(IRandom rand, GridPlan floorPlan) { int gapLength = Vertical ? floorPlan.GridHeight : floorPlan.GridWidth; int sideLength = Vertical ? floorPlan.GridWidth : floorPlan.GridHeight; if (gapLength < 3 || sideLength < 2) { CreateErrorPath(rand, floorPlan); return; } //add the body int chosenTier = FromCorners ? (rand.Next(2) * gapLength - 1) : rand.Next(1, gapLength - 1); RoomGen <T> roomGen = GiantHallGen.Pick(rand); if (roomGen == null) { roomGen = GenericRooms.Pick(rand); } floorPlan.AddRoom(new Rect(Vertical ? 0 : chosenTier, Vertical ? chosenTier : 0, Vertical ? sideLength : 1, Vertical ? 1 : sideLength), roomGen, this.LargeRoomComponents.Clone()); GenContextDebug.DebugProgress("Center Room"); //add the legs for (int ii = 0; ii < sideLength; ii++) { if (chosenTier > 0) { if (rand.Next(100) < LegPercent) { int roomTier = rand.Next(0, chosenTier); floorPlan.AddRoom(new Loc(Vertical ? ii : roomTier, Vertical ? roomTier : ii), GenericRooms.Pick(rand), this.RoomComponents.Clone()); for (int jj = roomTier; jj < chosenTier; jj++) { SafeAddHall(new LocRay4(new Loc(Vertical ? ii : jj, Vertical ? jj : ii), Vertical ? Dir4.Down : Dir4.Right), floorPlan, GenericHalls.Pick(rand), GetDefaultGen(), this.RoomComponents, this.HallComponents, true); } GenContextDebug.DebugProgress("Add Leg"); int hasRoom = -1; for (int jj = ii - 1; jj >= 0; jj--) { if (floorPlan.GetRoomPlan(new Loc(Vertical ? jj : roomTier, Vertical ? roomTier : jj)) != null) { hasRoom = jj; break; } } if (ii > 0 && hasRoom > -1) { if (rand.Next(100) < ConnectPercent) { for (int jj = ii; jj > hasRoom; jj--) { SafeAddHall(new LocRay4(new Loc(Vertical ? jj : roomTier, Vertical ? roomTier : jj), Vertical ? Dir4.Left : Dir4.Up), floorPlan, GenericHalls.Pick(rand), GetDefaultGen(), this.RoomComponents, this.HallComponents, true); GenContextDebug.DebugProgress("Connect Leg"); } } } } } if (chosenTier < gapLength - 1) { if (rand.Next(100) < LegPercent) { int roomTier = rand.Next(chosenTier + 1, gapLength); floorPlan.AddRoom(new Loc(Vertical ? ii : roomTier, Vertical ? roomTier : ii), GenericRooms.Pick(rand), this.RoomComponents.Clone()); for (int jj = chosenTier; jj < roomTier; jj++) { SafeAddHall(new LocRay4(new Loc(Vertical ? ii : jj, Vertical ? jj : ii), Vertical ? Dir4.Down : Dir4.Right), floorPlan, GenericHalls.Pick(rand), GetDefaultGen(), this.RoomComponents, this.HallComponents, true); } GenContextDebug.DebugProgress("Add Leg"); int hasRoom = -1; for (int jj = ii - 1; jj >= 0; jj--) { if (floorPlan.GetRoomPlan(new Loc(Vertical ? jj : roomTier, Vertical ? roomTier : jj)) != null) { hasRoom = jj; break; } } if (ii > 0 && hasRoom > -1) { if (rand.Next(100) < ConnectPercent) { for (int jj = ii; jj > hasRoom; jj--) { SafeAddHall(new LocRay4(new Loc(Vertical ? jj : roomTier, Vertical ? roomTier : jj), Vertical ? Dir4.Left : Dir4.Up), floorPlan, GenericHalls.Pick(rand), GetDefaultGen(), this.RoomComponents, this.HallComponents, true); GenContextDebug.DebugProgress("Connect Leg"); } } } } } } }