public bool ProvideCandidate(SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = null; if (!PotionOfReturnHelper.TryGetGateHitbox(settings.player, out Rectangle homeHitbox)) { return(false); } float distanceFromCursor = homeHitbox.ClosestPointInRect(settings.mousevec).Distance(settings.mousevec); _candidate.Reuse(distanceFromCursor); candidate = _candidate; return(true); }
public bool ProvideCandidate( SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = (ISmartInteractCandidate)null; Rectangle homeHitbox; if (!PotionOfReturnHelper.TryGetGateHitbox(settings.player, out homeHitbox)) { return(false); } this._candidate.Reuse(homeHitbox.ClosestPointInRect(settings.mousevec).Distance(settings.mousevec)); candidate = (ISmartInteractCandidate)this._candidate; return(true); }
public bool ProvideCandidate(SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = null; if (!settings.FullInteraction) { return(false); } List <int> listOfProjectilesToInteractWithHack = settings.player.GetListOfProjectilesToInteractWithHack(); bool flag = false; Vector2 mousevec = settings.mousevec; mousevec.ToPoint(); int num = -1; float projectileDistanceFromCursor = -1f; for (int i = 0; i < listOfProjectilesToInteractWithHack.Count; i++) { int num2 = listOfProjectilesToInteractWithHack[i]; Projectile projectile = Main.projectile[num2]; if (projectile.active) { float num3 = projectile.Hitbox.Distance(mousevec); if (num == -1 || Main.projectile[num].Hitbox.Distance(mousevec) > num3) { num = num2; projectileDistanceFromCursor = num3; } if (num3 == 0f) { flag = true; num = num2; projectileDistanceFromCursor = num3; break; } } } if (settings.DemandOnlyZeroDistanceTargets && !flag) { return(false); } if (num != -1) { _candidate.Reuse(num, projectileDistanceFromCursor); candidate = _candidate; return(true); } return(false); }
public bool ProvideCandidate(SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = null; if (!settings.FullInteraction) { return(false); } Rectangle value = Utils.CenteredRectangle(settings.player.Center, new Vector2(Player.tileRangeX, Player.tileRangeY) * 16f * 2f); Vector2 mousevec = settings.mousevec; mousevec.ToPoint(); bool flag = false; int num = -1; float npcDistanceFromCursor = -1f; for (int i = 0; i < 200; i++) { NPC nPC = Main.npc[i]; if (nPC.active && nPC.townNPC && nPC.Hitbox.Intersects(value) && !flag) { float num2 = nPC.Hitbox.Distance(mousevec); if (num == -1 || Main.npc[num].Hitbox.Distance(mousevec) > num2) { num = i; npcDistanceFromCursor = num2; } if (num2 == 0f) { flag = true; num = i; npcDistanceFromCursor = num2; break; } } } if (settings.DemandOnlyZeroDistanceTargets && !flag) { return(false); } if (num != -1) { _candidate.Reuse(num, npcDistanceFromCursor); candidate = _candidate; return(true); } return(false); }
public bool ProvideCandidate( SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = (ISmartInteractCandidate)null; if (!settings.FullInteraction) { return(false); } List <int> interactWithHack = settings.player.GetListOfProjectilesToInteractWithHack(); bool flag = false; Vector2 mousevec = settings.mousevec; mousevec.ToPoint(); int projectileIndex = -1; float projectileDistanceFromCursor = -1f; for (int index1 = 0; index1 < interactWithHack.Count; ++index1) { int index2 = interactWithHack[index1]; Projectile projectile = Main.projectile[index2]; if (projectile.active) { float num = projectile.Hitbox.Distance(mousevec); if ((projectileIndex == -1 ? 1 : ((double)Main.projectile[projectileIndex].Hitbox.Distance(mousevec) > (double)num ? 1 : 0)) != 0) { projectileIndex = index2; projectileDistanceFromCursor = num; } if ((double)num == 0.0) { flag = true; projectileIndex = index2; projectileDistanceFromCursor = num; break; } } } if (settings.DemandOnlyZeroDistanceTargets && !flag || projectileIndex == -1) { return(false); } this._candidate.Reuse(projectileIndex, projectileDistanceFromCursor); candidate = (ISmartInteractCandidate)this._candidate; return(true); }
public bool ProvideCandidate( SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = (ISmartInteractCandidate)null; if (!settings.FullInteraction) { return(false); } Rectangle rectangle = Utils.CenteredRectangle(settings.player.Center, new Vector2((float)Player.tileRangeX, (float)Player.tileRangeY) * 16f * 2f); Vector2 mousevec = settings.mousevec; mousevec.ToPoint(); bool flag = false; int npcIndex = -1; float npcDistanceFromCursor = -1f; for (int index = 0; index < 200; ++index) { NPC npc = Main.npc[index]; if (npc.active && npc.townNPC && (npc.Hitbox.Intersects(rectangle) && !flag)) { float num = npc.Hitbox.Distance(mousevec); if ((npcIndex == -1 ? 1 : ((double)Main.npc[npcIndex].Hitbox.Distance(mousevec) > (double)num ? 1 : 0)) != 0) { npcIndex = index; npcDistanceFromCursor = num; } if ((double)num == 0.0) { flag = true; npcIndex = index; npcDistanceFromCursor = num; break; } } } if (settings.DemandOnlyZeroDistanceTargets && !flag || npcIndex == -1) { return(false); } this._candidate.Reuse(npcIndex, npcDistanceFromCursor); candidate = (ISmartInteractCandidate)this._candidate; return(true); }
public void RunQuery(SmartInteractScanSettings settings) { this._candidates.Clear(); foreach (ISmartInteractBlockReasonProvider blockProvider in this._blockProviders) { if (blockProvider.ShouldBlockSmartInteract(settings)) { return; } } foreach (ISmartInteractCandidateProvider candidateProvider in this._candidateProvidersByOrderOfPriority) { candidateProvider.ClearSelfAndPrepareForCheck(); } foreach (ISmartInteractCandidateProvider candidateProvider in this._candidateProvidersByOrderOfPriority) { ISmartInteractCandidate candidate; if (candidateProvider.ProvideCandidate(settings, out candidate)) { this._candidates.Add(candidate); if ((double)candidate.DistanceFromCursor == 0.0) { break; } } } ISmartInteractCandidate interactCandidate = (ISmartInteractCandidate)null; foreach (ISmartInteractCandidate candidate in this._candidates) { if (interactCandidate == null || (double)interactCandidate.DistanceFromCursor > (double)candidate.DistanceFromCursor) { interactCandidate = candidate; } } interactCandidate?.WinCandidacy(); }
public void RunQuery(SmartInteractScanSettings settings) { _candidates.Clear(); foreach (ISmartInteractBlockReasonProvider blockProvider in _blockProviders) { if (blockProvider.ShouldBlockSmartInteract(settings)) { return; } } foreach (ISmartInteractCandidateProvider item in _candidateProvidersByOrderOfPriority) { item.ClearSelfAndPrepareForCheck(); } foreach (ISmartInteractCandidateProvider item2 in _candidateProvidersByOrderOfPriority) { if (item2.ProvideCandidate(settings, out ISmartInteractCandidate candidate)) { _candidates.Add(candidate); if (candidate.DistanceFromCursor == 0f) { break; } } } ISmartInteractCandidate smartInteractCandidate = null; foreach (ISmartInteractCandidate candidate2 in _candidates) { if (smartInteractCandidate == null || smartInteractCandidate.DistanceFromCursor > candidate2.DistanceFromCursor) { smartInteractCandidate = candidate2; } } smartInteractCandidate?.WinCandidacy(); }
public bool ProvideCandidate( SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = (ISmartInteractCandidate)null; Point tileCoordinates = settings.mousevec.ToTileCoordinates(); this.FillPotentialTargetTiles(settings); int num1 = -1; int num2 = -1; int AimedX = -1; int AimedY = -1; if (this.targets.Count > 0) { float num3 = -1f; Tuple <int, int> target = this.targets[0]; for (int index = 0; index < this.targets.Count; ++index) { float num4 = Vector2.Distance(new Vector2((float)this.targets[index].Item1, (float)this.targets[index].Item2) * 16f + Vector2.One * 8f, settings.mousevec); if ((double)num3 == -1.0 || (double)num4 <= (double)num3) { num3 = num4; target = this.targets[index]; } } if (Collision.InTileBounds(target.Item1, target.Item2, settings.LX, settings.LY, settings.HX, settings.HY)) { num1 = target.Item1; num2 = target.Item2; } } bool flag1 = false; for (int index1 = 0; index1 < this.targets.Count; ++index1) { int index2 = this.targets[index1].Item1; int index3 = this.targets[index1].Item2; Tile tile = Main.tile[index2, index3]; int num3 = 0; int num4 = 0; int num5 = 18; int num6 = 18; int num7 = 2; switch (tile.type) { case 10: num3 = 1; num4 = 3; num7 = 0; break; case 11: case 356: case 410: case 470: case 480: case 509: num3 = 2; num4 = 3; num7 = 0; break; case 15: case 497: num3 = 1; num4 = 2; num7 = 4; break; case 21: case 55: case 85: case 97: case 125: case 132: case 287: case 335: case 386: case 411: case 425: case 441: case 467: case 468: case 573: case 621: num3 = 2; num4 = 2; break; case 29: case 387: num3 = 2; num4 = 1; break; case 79: case 139: case 510: case 511: num3 = 2; num4 = 2; num7 = 0; break; case 88: num3 = 3; num4 = 1; num7 = 0; break; case 89: case 215: case 237: case 377: num3 = 3; num4 = 2; break; case 102: case 463: case 475: case 597: num3 = 3; num4 = 4; break; case 104: num3 = 2; num4 = 5; break; case 136: case 144: case 494: num3 = 1; num4 = 1; num7 = 0; break; case 207: num3 = 2; num4 = 4; num7 = 0; break; case 209: num3 = 4; num4 = 3; num7 = 0; break; case 212: num3 = 4; num4 = 3; break; case 216: case 338: num3 = 1; num4 = 2; break; case 354: case 455: case 491: num3 = 3; num4 = 3; num7 = 0; break; case 388: case 389: num3 = 1; num4 = 5; break; case 487: num3 = 4; num4 = 2; num7 = 0; break; } if (num3 != 0 && num4 != 0) { int lx = index2 - (int)tile.frameX % (num5 * num3) / num5; int ly = index3 - (int)tile.frameY % (num6 * num4 + num7) / num6; bool flag2 = Collision.InTileBounds(num1, num2, lx, ly, lx + num3 - 1, ly + num4 - 1); bool flag3 = Collision.InTileBounds(tileCoordinates.X, tileCoordinates.Y, lx, ly, lx + num3 - 1, ly + num4 - 1); if (flag3) { AimedX = tileCoordinates.X; AimedY = tileCoordinates.Y; } if (!settings.FullInteraction) { flag2 &= flag3; } if (flag1) { flag2 = false; } for (int x = lx; x < lx + num3; ++x) { for (int y = ly; y < ly + num4; ++y) { Point point = new Point(x, y); if (!Main.SmartInteractTileCoords.Contains(point)) { if (flag2) { Main.SmartInteractTileCoordsSelected.Add(point); } if (flag2 || settings.FullInteraction) { Main.SmartInteractTileCoords.Add(point); } } } } if (!flag1 & flag2) { flag1 = true; } } } if (settings.DemandOnlyZeroDistanceTargets) { if (AimedX == -1 || AimedY == -1) { return(false); } this._candidate.Reuse(true, 0.0f, AimedX, AimedY, settings.LX - 10, settings.LY - 10, settings.HX + 10, settings.HY + 10); candidate = (ISmartInteractCandidate)this._candidate; return(true); } if (num1 == -1 || num2 == -1) { return(false); } this._candidate.Reuse(false, new Rectangle(num1 * 16, num2 * 16, 16, 16).ClosestPointInRect(settings.mousevec).Distance(settings.mousevec), num1, num2, settings.LX - 10, settings.LY - 10, settings.HX + 10, settings.HY + 10); candidate = (ISmartInteractCandidate)this._candidate; return(true); }
private void FillPotentialTargetTiles(SmartInteractScanSettings settings) { for (int lx = settings.LX; lx <= settings.HX; ++lx) { for (int ly = settings.LY; ly <= settings.HY; ++ly) { Tile tile = Main.tile[lx, ly]; if (tile != null && tile.active()) { switch (tile.type) { case 10: case 11: case 21: case 29: case 55: case 79: case 85: case 88: case 89: case 97: case 102: case 104: case 125: case 132: case 136: case 139: case 144: case 207: case 209: case 215: case 216: case 287: case 335: case 338: case 354: case 377: case 386: case 387: case 388: case 389: case 410: case 411: case 425: case 441: case 455: case 463: case 467: case 468: case 470: case 475: case 480: case 487: case 491: case 494: case 509: case 510: case 511: case 573: case 597: case 621: this.targets.Add(new Tuple <int, int>(lx, ly)); continue; case 15: case 497: if (settings.player.IsWithinSnappngRangeToTile(lx, ly, 40)) { this.targets.Add(new Tuple <int, int>(lx, ly)); continue; } continue; case 212: if (settings.player.HasItem(949)) { this.targets.Add(new Tuple <int, int>(lx, ly)); continue; } continue; case 237: if (settings.player.HasItem(1293)) { this.targets.Add(new Tuple <int, int>(lx, ly)); continue; } continue; case 356: if (!Main.fastForwardTime && (Main.netMode == 1 || Main.sundialCooldown == 0)) { this.targets.Add(new Tuple <int, int>(lx, ly)); continue; } continue; default: continue; } } } } }
public bool ProvideCandidate(SmartInteractScanSettings settings, out ISmartInteractCandidate candidate) { candidate = null; Point point = settings.mousevec.ToTileCoordinates(); FillPotentialTargetTiles(settings); int num = -1; int num2 = -1; int num3 = -1; int num4 = -1; if (targets.Count > 0) { float num5 = -1f; Tuple <int, int> tuple = targets[0]; for (int i = 0; i < targets.Count; i++) { float num6 = Vector2.Distance(new Vector2(targets[i].Item1, targets[i].Item2) * 16f + Vector2.One * 8f, settings.mousevec); if (num5 == -1f || num6 <= num5) { num5 = num6; tuple = targets[i]; } } if (Collision.InTileBounds(tuple.Item1, tuple.Item2, settings.LX, settings.LY, settings.HX, settings.HY)) { num = tuple.Item1; num2 = tuple.Item2; } } bool flag = false; for (int j = 0; j < targets.Count; j++) { int item = targets[j].Item1; int item2 = targets[j].Item2; Tile tile = Main.tile[item, item2]; int num7 = 0; int num8 = 0; int num9 = 18; int num10 = 18; int num11 = 2; switch (tile.type) { case 136: case 144: case 494: num7 = 1; num8 = 1; num11 = 0; break; case 216: case 338: num7 = 1; num8 = 2; break; case 15: case 497: num7 = 1; num8 = 2; num11 = 4; break; case 10: num7 = 1; num8 = 3; num11 = 0; break; case 388: case 389: num7 = 1; num8 = 5; break; case 29: case 387: num7 = 2; num8 = 1; break; case 21: case 55: case 85: case 97: case 125: case 132: case 287: case 335: case 386: case 411: case 425: case 441: case 467: case 468: case 573: case 621: num7 = 2; num8 = 2; break; case 79: case 139: case 510: case 511: num7 = 2; num8 = 2; num11 = 0; break; case 11: case 356: case 410: case 470: case 480: case 509: num7 = 2; num8 = 3; num11 = 0; break; case 207: num7 = 2; num8 = 4; num11 = 0; break; case 104: num7 = 2; num8 = 5; break; case 88: num7 = 3; num8 = 1; num11 = 0; break; case 89: case 215: case 237: case 377: num7 = 3; num8 = 2; break; case 354: case 455: case 491: num7 = 3; num8 = 3; num11 = 0; break; case 487: num7 = 4; num8 = 2; num11 = 0; break; case 212: num7 = 4; num8 = 3; break; case 209: num7 = 4; num8 = 3; num11 = 0; break; case 102: case 463: case 475: case 597: num7 = 3; num8 = 4; break; } if (num7 == 0 || num8 == 0) { continue; } int num12 = item - tile.frameX % (num9 * num7) / num9; int num13 = item2 - tile.frameY % (num10 * num8 + num11) / num10; bool flag2 = Collision.InTileBounds(num, num2, num12, num13, num12 + num7 - 1, num13 + num8 - 1); bool flag3 = Collision.InTileBounds(point.X, point.Y, num12, num13, num12 + num7 - 1, num13 + num8 - 1); if (flag3) { num3 = point.X; num4 = point.Y; } if (!settings.FullInteraction) { flag2 = (flag2 && flag3); } if (flag) { flag2 = false; } for (int k = num12; k < num12 + num7; k++) { for (int l = num13; l < num13 + num8; l++) { Point item3 = new Point(k, l); if (!Main.SmartInteractTileCoords.Contains(item3)) { if (flag2) { Main.SmartInteractTileCoordsSelected.Add(item3); } if (flag2 || settings.FullInteraction) { Main.SmartInteractTileCoords.Add(item3); } } } } if (!flag && flag2) { flag = true; } } if (settings.DemandOnlyZeroDistanceTargets) { if (num3 != -1 && num4 != -1) { _candidate.Reuse(strictSettings: true, 0f, num3, num4, settings.LX - 10, settings.LY - 10, settings.HX + 10, settings.HY + 10); candidate = _candidate; return(true); } return(false); } if (num != -1 && num2 != -1) { float distanceFromCursor = new Rectangle(num * 16, num2 * 16, 16, 16).ClosestPointInRect(settings.mousevec).Distance(settings.mousevec); _candidate.Reuse(strictSettings: false, distanceFromCursor, num, num2, settings.LX - 10, settings.LY - 10, settings.HX + 10, settings.HY + 10); candidate = _candidate; return(true); } return(false); }
private void FillPotentialTargetTiles(SmartInteractScanSettings settings) { for (int i = settings.LX; i <= settings.HX; i++) { for (int j = settings.LY; j <= settings.HY; j++) { Tile tile = Main.tile[i, j]; if (tile == null || !tile.active()) { continue; } switch (tile.type) { case 10: case 11: case 21: case 29: case 55: case 79: case 85: case 88: case 89: case 97: case 102: case 104: case 125: case 132: case 136: case 139: case 144: case 207: case 209: case 215: case 216: case 287: case 335: case 338: case 354: case 377: case 386: case 387: case 388: case 389: case 410: case 411: case 425: case 441: case 455: case 463: case 467: case 468: case 470: case 475: case 480: case 487: case 491: case 494: case 509: case 510: case 511: case 573: case 597: case 621: targets.Add(new Tuple <int, int>(i, j)); break; case 15: case 497: if (settings.player.IsWithinSnappngRangeToTile(i, j, 40)) { targets.Add(new Tuple <int, int>(i, j)); } break; case 237: if (settings.player.HasItem(1293)) { targets.Add(new Tuple <int, int>(i, j)); } break; case 212: if (settings.player.HasItem(949)) { targets.Add(new Tuple <int, int>(i, j)); } break; case 356: if (!Main.fastForwardTime && (Main.netMode == 1 || Main.sundialCooldown == 0)) { targets.Add(new Tuple <int, int>(i, j)); } break; } } } }