public bool FindPath(int x, int y, int minimumLength, bool debugMode = false) { TrackGenerator.TrackHistory[] historyCache = this._historyCache; int num = 0; Tile[,] arg_0E_0 = Main.tile; bool flag = true; int num2 = (new Random().Next(2) == 0) ? 1 : -1; if (debugMode) { num2 = Main.player[Main.myPlayer].direction; } int num3 = 1; int num4 = 0; int num5 = 400; bool flag2 = false; int num6 = 150; int num7 = 0; int num8 = 1000000; while (num8 > 0 && flag && num < historyCache.Length - 1) { num8--; historyCache[num] = new TrackGenerator.TrackHistory(x, y, num3); bool flag3 = false; int num9 = 1; if (num > minimumLength >> 1) { num9 = -1; } else if (num > (minimumLength >> 1) - 5) { num9 = 0; } if (flag2) { int num10 = 0; int num11 = num6; bool flag4 = false; for (int i = Math.Min(1, num3 + 1); i >= Math.Max(-1, num3 - 1); i--) { int j; for (j = 0; j <= num6; j++) { if (this.IsLocationEmpty(x + (j + 1) * num2, y + (j + 1) * i * num9)) { flag4 = true; break; } } if (j < num11) { num11 = j; num10 = i; } } if (flag4) { num3 = num10; for (int k = 0; k < num11 - 1; k++) { num++; x += num2; y += num3 * num9; historyCache[num] = new TrackGenerator.TrackHistory(x, y, num3); num7 = num; } x += num2; y += num3 * num9; num4 = num + 1; flag2 = false; } num6 -= num11; if (num6 < 0) { flag = false; } } else { for (int l = Math.Min(1, num3 + 1); l >= Math.Max(-1, num3 - 1); l--) { if (this.IsLocationEmpty(x + num2, y + l * num9)) { num3 = l; flag3 = true; x += num2; y += num3 * num9; num4 = num + 1; break; } } if (!flag3) { while (num > num7 && y == (int)historyCache[num].Y) { num--; } x = (int)historyCache[num].X; y = (int)historyCache[num].Y; num3 = (int)(historyCache[num].YDirection - 1); num5--; if (num5 <= 0) { num = num4; x = (int)historyCache[num].X; y = (int)historyCache[num].Y; num3 = (int)historyCache[num].YDirection; flag2 = true; num5 = 200; } num--; } } num++; } if (num4 > minimumLength || debugMode) { this.SmoothTrack(historyCache, num4); if (!debugMode) { for (int m = 0; m < num4; m++) { for (int n = -1; n < 7; n++) { if (!this.CanTrackBePlaced((int)historyCache[m].X, (int)historyCache[m].Y - n)) { return false; } } } } for (int num12 = 0; num12 < num4; num12++) { TrackGenerator.TrackHistory trackHistory = historyCache[num12]; for (int num13 = 0; num13 < 6; num13++) { Main.tile[(int)trackHistory.X, (int)trackHistory.Y - num13].active(false); } } for (int num14 = 0; num14 < num4; num14++) { TrackGenerator.TrackHistory trackHistory2 = historyCache[num14]; Tile.SmoothSlope((int)trackHistory2.X, (int)(trackHistory2.Y + 1), true); Tile.SmoothSlope((int)trackHistory2.X, (int)(trackHistory2.Y - 6), true); bool wire = Main.tile[(int)trackHistory2.X, (int)trackHistory2.Y].wire(); Main.tile[(int)trackHistory2.X, (int)trackHistory2.Y].ResetToType(314); Main.tile[(int)trackHistory2.X, (int)trackHistory2.Y].wire(wire); if (num14 != 0) { for (int num15 = 0; num15 < 6; num15++) { WorldUtils.TileFrame((int)historyCache[num14 - 1].X, (int)historyCache[num14 - 1].Y - num15, true); } if (num14 == num4 - 1) { for (int num16 = 0; num16 < 6; num16++) { WorldUtils.TileFrame((int)trackHistory2.X, (int)trackHistory2.Y - num16, true); } } } } return true; } return false; }
private void PlacePath() { bool[] flagArray = new bool[this._length]; for (int index1 = 0; index1 < this._length; ++index1) { if (WorldGen.genRand.Next(7) == 0) { this.playerHeight = WorldGen.genRand.Next(5, 9); } for (int index2 = 0; index2 < this.playerHeight; ++index2) { if (Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2 - 1].wall == (ushort)244) { Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2 - 1].wall = (ushort)0; } if (Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2].wall == (ushort)244) { Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2].wall = (ushort)0; } if (Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2 + 1].wall == (ushort)244) { Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2 + 1].wall = (ushort)0; } if (Main.tile[(int)this._history[index1].X, (int)this._history[index1].Y - index2].type == (ushort)135) { flagArray[index1] = true; } WorldGen.KillTile((int)this._history[index1].X, (int)this._history[index1].Y - index2, false, false, true); } } for (int index1 = 0; index1 < this._length; ++index1) { if (WorldGen.genRand.Next(7) == 0) { this.playerHeight = WorldGen.genRand.Next(5, 9); } TrackGenerator.TrackHistory trackHistory = this._history[index1]; Tile.SmoothSlope((int)trackHistory.X, (int)trackHistory.Y + 1, true, false); Tile.SmoothSlope((int)trackHistory.X, (int)trackHistory.Y - this.playerHeight, true, false); bool wire = Main.tile[(int)trackHistory.X, (int)trackHistory.Y].wire(); if (flagArray[index1] && index1 < this._length && (index1 > 0 && (int)this._history[index1 - 1].Y == (int)trackHistory.Y) && (int)this._history[index1 + 1].Y == (int)trackHistory.Y) { Main.tile[(int)trackHistory.X, (int)trackHistory.Y].ClearEverything(); WorldGen.PlaceTile((int)trackHistory.X, (int)trackHistory.Y, 314, false, true, -1, 1); } else { Main.tile[(int)trackHistory.X, (int)trackHistory.Y].ResetToType((ushort)314); } Main.tile[(int)trackHistory.X, (int)trackHistory.Y].wire(wire); if (index1 != 0) { for (int index2 = 0; index2 < 8; ++index2) { WorldUtils.TileFrame((int)this._history[index1 - 1].X, (int)this._history[index1 - 1].Y - index2, true); } if (index1 == this._length - 1) { for (int index2 = 0; index2 < this.playerHeight; ++index2) { WorldUtils.TileFrame((int)trackHistory.X, (int)trackHistory.Y - index2, true); } } } } }
public bool FindPath(int x, int y, int minimumLength, bool debugMode = false) { TrackGenerator.TrackHistory[] trackHistory = this._historyCache; int num = 0; TileProvider tileArray = Main.tile; bool flag = true; int num1 = ((new Random()).Next(2) == 0 ? 1 : -1); if (debugMode) { num1 = Main.player[Main.myPlayer].direction; } int yDirection = 1; int num2 = 0; int num3 = 400; bool flag1 = false; int num4 = 150; int num5 = 0; int num6 = 1000000; while (num6 > 0 && flag && num < (int)trackHistory.Length - 1) { num6--; trackHistory[num] = new TrackGenerator.TrackHistory(x, y, yDirection); bool flag2 = false; int num7 = 1; if (num > minimumLength >> 1) { num7 = -1; } else if (num > (minimumLength >> 1) - 5) { num7 = 0; } if (!flag1) { int num8 = Math.Min(1, yDirection + 1); while (num8 >= Math.Max(-1, yDirection - 1)) { if (!this.IsLocationEmpty(x + num1, y + num8 * num7)) { num8--; } else { yDirection = num8; flag2 = true; x = x + num1; y = y + yDirection * num7; num2 = num + 1; break; } } if (!flag2) { while (num > num5 && y == trackHistory[num].Y) { num--; } x = trackHistory[num].X; y = trackHistory[num].Y; yDirection = trackHistory[num].YDirection - 1; num3--; if (num3 <= 0) { num = num2; x = trackHistory[num].X; y = trackHistory[num].Y; yDirection = trackHistory[num].YDirection; flag1 = true; num3 = 200; } num--; } } else { int num9 = 0; int num10 = num4; bool flag3 = false; for (int i = Math.Min(1, yDirection + 1); i >= Math.Max(-1, yDirection - 1); i--) { int num11 = 0; while (num11 <= num4) { if (!this.IsLocationEmpty(x + (num11 + 1) * num1, y + (num11 + 1) * i * num7)) { num11++; } else { flag3 = true; break; } } if (num11 < num10) { num10 = num11; num9 = i; } } if (flag3) { yDirection = num9; for (int j = 0; j < num10 - 1; j++) { num++; x = x + num1; y = y + yDirection * num7; trackHistory[num] = new TrackGenerator.TrackHistory(x, y, yDirection); num5 = num; } x = x + num1; y = y + yDirection * num7; num2 = num + 1; flag1 = false; } num4 = num4 - num10; if (num4 < 0) { flag = false; } } num++; } if (num2 <= minimumLength && !debugMode) { return false; } this.SmoothTrack(trackHistory, num2); if (!debugMode) { for (int k = 0; k < num2; k++) { for (int l = -1; l < 7; l++) { if (!this.CanTrackBePlaced(trackHistory[k].X, trackHistory[k].Y - l)) { return false; } } } } for (int m = 0; m < num2; m++) { TrackGenerator.TrackHistory trackHistory1 = trackHistory[m]; for (int n = 0; n < 6; n++) { Main.tile[trackHistory1.X, trackHistory1.Y - n].active(false); } } for (int o = 0; o < num2; o++) { TrackGenerator.TrackHistory trackHistory2 = trackHistory[o]; Tile.SmoothSlope(trackHistory2.X, trackHistory2.Y + 1, true); Tile.SmoothSlope(trackHistory2.X, trackHistory2.Y - 6, true); Main.tile[trackHistory2.X, trackHistory2.Y].ResetToType(314); if (o != 0) { for (int p = 0; p < 6; p++) { WorldUtils.TileFrame(trackHistory[o - 1].X, trackHistory[o - 1].Y - p, true); } if (o == num2 - 1) { for (int q = 0; q < 6; q++) { WorldUtils.TileFrame(trackHistory2.X, trackHistory2.Y - q, true); } } } } return true; }
public bool FindPath(int x, int y, int minimumLength, bool debugMode = false) { TrackGenerator.TrackHistory[] historyCache = this._historyCache; int index1 = 0; Tile[,] tile = Main.tile; bool flag1 = true; int num1 = WorldGen.genRand.Next(2) == 0 ? 1 : -1; if (debugMode) { num1 = Main.player[Main.myPlayer].direction; } int yDirection = 1; int length = 0; int num2 = 400; bool flag2 = false; int num3 = 150; int num4 = 0; for (int index2 = 1000000; index2 > 0 && flag1 && index1 < historyCache.Length - 1; ++index1) { --index2; historyCache[index1] = new TrackGenerator.TrackHistory(x, y, yDirection); bool flag3 = false; int num5 = 1; if (index1 > minimumLength >> 1) { num5 = -1; } else if (index1 > (minimumLength >> 1) - 5) { num5 = 0; } if (flag2) { int num6 = 0; int num7 = num3; bool flag4 = false; for (int index3 = Math.Min(1, yDirection + 1); index3 >= Math.Max(-1, yDirection - 1); --index3) { int num8; for (num8 = 0; num8 <= num3; ++num8) { if (this.IsLocationEmpty(x + (num8 + 1) * num1, y + (num8 + 1) * index3 * num5)) { flag4 = true; break; } } if (num8 < num7) { num7 = num8; num6 = index3; } } if (flag4) { yDirection = num6; for (int index3 = 0; index3 < num7 - 1; ++index3) { ++index1; x += num1; y += yDirection * num5; historyCache[index1] = new TrackGenerator.TrackHistory(x, y, yDirection); num4 = index1; } x += num1; y += yDirection * num5; length = index1 + 1; flag2 = false; } num3 -= num7; if (num3 < 0) { flag1 = false; } } else { for (int index3 = Math.Min(1, yDirection + 1); index3 >= Math.Max(-1, yDirection - 1); --index3) { if (this.IsLocationEmpty(x + num1, y + index3 * num5)) { yDirection = index3; flag3 = true; x += num1; y += yDirection * num5; length = index1 + 1; break; } } if (!flag3) { while (index1 > num4 && y == (int)historyCache[index1].Y) { --index1; } x = (int)historyCache[index1].X; y = (int)historyCache[index1].Y; yDirection = (int)historyCache[index1].YDirection - 1; --num2; if (num2 <= 0) { index1 = length; x = (int)historyCache[index1].X; y = (int)historyCache[index1].Y; yDirection = (int)historyCache[index1].YDirection; flag2 = true; num2 = 200; } --index1; } } } if (length <= minimumLength && !debugMode) { return(false); } this.SmoothTrack(historyCache, length); if (!debugMode) { for (int index2 = 0; index2 < length; ++index2) { for (int index3 = -1; index3 < 7; ++index3) { if (!this.CanTrackBePlaced((int)historyCache[index2].X, (int)historyCache[index2].Y - index3)) { return(false); } } } } for (int index2 = 0; index2 < length; ++index2) { TrackGenerator.TrackHistory trackHistory = historyCache[index2]; for (int index3 = 0; index3 < 6; ++index3) { Main.tile[(int)trackHistory.X, (int)trackHistory.Y - index3].active(false); } } for (int index2 = 0; index2 < length; ++index2) { TrackGenerator.TrackHistory trackHistory = historyCache[index2]; Tile.SmoothSlope((int)trackHistory.X, (int)trackHistory.Y + 1, true); Tile.SmoothSlope((int)trackHistory.X, (int)trackHistory.Y - 6, true); bool wire = Main.tile[(int)trackHistory.X, (int)trackHistory.Y].wire(); Main.tile[(int)trackHistory.X, (int)trackHistory.Y].ResetToType((ushort)314); Main.tile[(int)trackHistory.X, (int)trackHistory.Y].wire(wire); if (index2 != 0) { for (int index3 = 0; index3 < 6; ++index3) { WorldUtils.TileFrame((int)historyCache[index2 - 1].X, (int)historyCache[index2 - 1].Y - index3, true); } if (index2 == length - 1) { for (int index3 = 0; index3 < 6; ++index3) { WorldUtils.TileFrame((int)trackHistory.X, (int)trackHistory.Y - index3, true); } } } } return(true); }
public bool FindPath(int x, int y, int minimumLength, bool debugMode = false) { TrackGenerator.TrackHistory[] trackHistory = this._historyCache; int num = 0; Tile[,] tileArray = Main.tile; bool flag = true; int num1 = ((new Random()).Next(2) == 0 ? 1 : -1); if (debugMode) { num1 = Main.player[Main.myPlayer].direction; } int yDirection = 1; int num2 = 0; int num3 = 400; bool flag1 = false; int num4 = 150; int num5 = 0; int num6 = 1000000; while (num6 > 0 && flag && num < (int)trackHistory.Length - 1) { num6--; trackHistory[num] = new TrackGenerator.TrackHistory(x, y, yDirection); bool flag2 = false; int num7 = 1; if (num > minimumLength >> 1) { num7 = -1; } else if (num > (minimumLength >> 1) - 5) { num7 = 0; } if (!flag1) { int num8 = Math.Min(1, yDirection + 1); while (num8 >= Math.Max(-1, yDirection - 1)) { if (!this.IsLocationEmpty(x + num1, y + num8 * num7)) { num8--; } else { yDirection = num8; flag2 = true; x = x + num1; y = y + yDirection * num7; num2 = num + 1; break; } } if (!flag2) { while (num > num5 && y == trackHistory[num].Y) { num--; } x = trackHistory[num].X; y = trackHistory[num].Y; yDirection = trackHistory[num].YDirection - 1; num3--; if (num3 <= 0) { num = num2; x = trackHistory[num].X; y = trackHistory[num].Y; yDirection = trackHistory[num].YDirection; flag1 = true; num3 = 200; } num--; } } else { int num9 = 0; int num10 = num4; bool flag3 = false; for (int i = Math.Min(1, yDirection + 1); i >= Math.Max(-1, yDirection - 1); i--) { int num11 = 0; while (num11 <= num4) { if (!this.IsLocationEmpty(x + (num11 + 1) * num1, y + (num11 + 1) * i * num7)) { num11++; } else { flag3 = true; break; } } if (num11 < num10) { num10 = num11; num9 = i; } } if (flag3) { yDirection = num9; for (int j = 0; j < num10 - 1; j++) { num++; x = x + num1; y = y + yDirection * num7; trackHistory[num] = new TrackGenerator.TrackHistory(x, y, yDirection); num5 = num; } x = x + num1; y = y + yDirection * num7; num2 = num + 1; flag1 = false; } num4 = num4 - num10; if (num4 < 0) { flag = false; } } num++; } if (num2 <= minimumLength && !debugMode) { return(false); } this.SmoothTrack(trackHistory, num2); if (!debugMode) { for (int k = 0; k < num2; k++) { for (int l = -1; l < 7; l++) { if (!this.CanTrackBePlaced(trackHistory[k].X, trackHistory[k].Y - l)) { return(false); } } } } for (int m = 0; m < num2; m++) { TrackGenerator.TrackHistory trackHistory1 = trackHistory[m]; for (int n = 0; n < 6; n++) { Main.tile[trackHistory1.X, trackHistory1.Y - n].active(false); } } for (int o = 0; o < num2; o++) { TrackGenerator.TrackHistory trackHistory2 = trackHistory[o]; Tile.SmoothSlope(trackHistory2.X, trackHistory2.Y + 1, true); Tile.SmoothSlope(trackHistory2.X, trackHistory2.Y - 6, true); Main.tile[trackHistory2.X, trackHistory2.Y].ResetToType(314); if (o != 0) { for (int p = 0; p < 6; p++) { WorldUtils.TileFrame(trackHistory[o - 1].X, trackHistory[o - 1].Y - p, true); } if (o == num2 - 1) { for (int q = 0; q < 6; q++) { WorldUtils.TileFrame(trackHistory2.X, trackHistory2.Y - q, true); } } } } return(true); }
// Token: 0x06000F66 RID: 3942 RVA: 0x003F4864 File Offset: 0x003F2A64 public bool FindPath(int x, int y, int minimumLength, bool debugMode = false) { TrackGenerator.TrackHistory[] historyCache = this._historyCache; int num = 0; Tile[,] arg_0E_0 = Main.tile; bool flag = true; int num2 = (WorldGen.genRand.Next(2) == 0) ? 1 : -1; if (debugMode) { num2 = Main.player[Main.myPlayer].direction; } int num3 = 1; int num4 = 0; int num5 = 400; bool flag2 = false; int num6 = 150; int num7 = 0; int num8 = 1000000; while ((num8 > 0 & flag) && num < historyCache.Length - 1) { num8--; historyCache[num] = new TrackGenerator.TrackHistory(x, y, num3); bool flag3 = false; int num9 = 1; if (num > minimumLength >> 1) { num9 = -1; } else if (num > (minimumLength >> 1) - 5) { num9 = 0; } if (flag2) { int num10 = 0; int num11 = num6; bool flag4 = false; for (int i = Math.Min(1, num3 + 1); i >= Math.Max(-1, num3 - 1); i--) { int j; for (j = 0; j <= num6; j++) { if (this.IsLocationEmpty(x + (j + 1) * num2, y + (j + 1) * i * num9)) { flag4 = true; break; } } if (j < num11) { num11 = j; num10 = i; } } if (flag4) { num3 = num10; for (int k = 0; k < num11 - 1; k++) { num++; x += num2; y += num3 * num9; historyCache[num] = new TrackGenerator.TrackHistory(x, y, num3); num7 = num; } x += num2; y += num3 * num9; num4 = num + 1; flag2 = false; } num6 -= num11; if (num6 < 0) { flag = false; } } else { for (int l = Math.Min(1, num3 + 1); l >= Math.Max(-1, num3 - 1); l--) { if (this.IsLocationEmpty(x + num2, y + l * num9)) { num3 = l; flag3 = true; x += num2; y += num3 * num9; num4 = num + 1; break; } } if (!flag3) { while (num > num7 && y == (int)historyCache[num].Y) { num--; } x = (int)historyCache[num].X; y = (int)historyCache[num].Y; num3 = (int)(historyCache[num].YDirection - 1); num5--; if (num5 <= 0) { num = num4; x = (int)historyCache[num].X; y = (int)historyCache[num].Y; num3 = (int)historyCache[num].YDirection; flag2 = true; num5 = 200; } num--; } } num++; } if (num4 > minimumLength | debugMode) { this.SmoothTrack(historyCache, num4); if (!debugMode) { for (int m = 0; m < num4; m++) { for (int n = -1; n < 7; n++) { if (!this.CanTrackBePlaced((int)historyCache[m].X, (int)historyCache[m].Y - n)) { return(false); } } } } for (int num12 = 0; num12 < num4; num12++) { TrackGenerator.TrackHistory trackHistory = historyCache[num12]; for (int num13 = 0; num13 < 6; num13++) { Main.tile[(int)trackHistory.X, (int)trackHistory.Y - num13].active(false); } } for (int num14 = 0; num14 < num4; num14++) { TrackGenerator.TrackHistory trackHistory2 = historyCache[num14]; Tile.SmoothSlope((int)trackHistory2.X, (int)(trackHistory2.Y + 1), true); Tile.SmoothSlope((int)trackHistory2.X, (int)(trackHistory2.Y - 6), true); bool wire = Main.tile[(int)trackHistory2.X, (int)trackHistory2.Y].wire(); Main.tile[(int)trackHistory2.X, (int)trackHistory2.Y].ResetToType(314); Main.tile[(int)trackHistory2.X, (int)trackHistory2.Y].wire(wire); if (num14 != 0) { for (int num15 = 0; num15 < 6; num15++) { WorldUtils.TileFrame((int)historyCache[num14 - 1].X, (int)historyCache[num14 - 1].Y - num15, true); } if (num14 == num4 - 1) { for (int num16 = 0; num16 < 6; num16++) { WorldUtils.TileFrame((int)trackHistory2.X, (int)trackHistory2.Y - num16, true); } } } } return(true); } return(false); }