s4000

DAV_PoolsList

Dec 24th, 2020 (edited)
2,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 19.89 KB | None | 0 0
  1. // version 2
  2.  
  3. using System;
  4. using System.Linq;
  5. using System.Collections.Generic;
  6. using Turbo.Plugins.Default;
  7.  
  8. namespace Turbo.Plugins.DAV
  9. {
  10.     public class DAV_PoolsList : BasePlugin, IInGameTopPainter, IInGameWorldPainter, IAfterCollectHandler, IKeyEventHandler, INewAreaHandler {
  11.         public bool resetWayPoint { get; set; }
  12.  
  13.         public SharpDX.DirectInput.Key Key { get; set; }
  14.         public bool showAlways { get; set; }
  15.         public bool showALLPool { get; set; }
  16.         public float xPos { get; set; }
  17.         public float yPos { get; set; }
  18.         public float iconSize { get; set; }
  19.         public string PoolSumHeader { get; set; }
  20.         public string nearWayPointName { get; set; }
  21.         public IFont Font_Pool_Summary { get; set; }
  22.         public Func<int, int, int, string> PoolSumMessage { get; set; }
  23.  
  24.         public bool showMapName { get; set; }
  25.         public float nullOffsetRatioX { get; set; }
  26.         public float mapOffsetX { get; set; }
  27.         public float mapOffsetY { get; set; }
  28.         public IFont[] Font_Pool { get; set; } = new IFont[2];
  29.         public Func<int, string>[] mapPoolMessage { get; set; } = new Func<int, string>[2];
  30.  
  31.         public bool skipPoolDecorator { get; set; }
  32.         public float[] showInDistance { get; set; } = new float[2];
  33.         public WorldDecoratorCollection[] PoolDecorator { get; set; } = new WorldDecoratorCollection[2];
  34.  
  35.         private bool showSummary { get; set; } = false;
  36.         private int lastAct { get; set; } = 0;
  37.         private uint lastWayPointSno { get; set; } = 0;
  38.         private string summaryMessage { get; set; }
  39.         private ITexture[] poolTexture { get; set; } = new ITexture[2];
  40.         private int poolTotal { get; set; } = 0;
  41.         private int[] poolFind { get; set; } = new int[] { 0, 0, 0, 0, 0, 0 };
  42.         private int[] poolUsed { get; set; } = new int[] { 0, 0, 0, 0, 0, 0 };
  43.         private List<DAV_WayPointSno> wayPointList { get; set; } = new List<DAV_WayPointSno>();
  44.         private Dictionary<string, DAV_PoolInfo> PoolMarkers { get; set; } = new Dictionary<string, DAV_PoolInfo>();
  45.  
  46.         public DAV_PoolsList() {
  47.             Enabled = true;
  48.         }
  49.        
  50.         public override void Load(IController hud) {
  51.             base.Load(hud);
  52.  
  53.             resetWayPoint = true; // reset waypoint data, WorldId vary in different game? (W.T.F.)
  54.  
  55.             Key = SharpDX.DirectInput.Key.E;
  56.             xPos = 770; // Hud.Window.Size.Width * 0.4f;
  57.             yPos = 10; // Hud.Window.Size.Height * 0.01f;
  58.             iconSize = 80;
  59.             showAlways = true;
  60.             showALLPool = true; // summary show qty even if all pool used in that Act
  61.             PoolSumHeader = "Pool Summary";
  62.             nearWayPointName = "WayPoint"; // map name if in the waypoint map (cant use the game data as the marker may be "far far away")
  63.             PoolSumMessage = (act, qtyExist, qtyTotal) => "A" + act.ToString() + " : " + qtyExist.ToString() + " Pool out of " + qtyTotal.ToString();
  64.             Font_Pool_Summary = Hud.Render.CreateFont("Arial", 8f, 250, 255, 250, 0, false, false, false);
  65.  
  66.             // Array : 0 for Available Pool, 1 for Used Pool
  67.             showMapName = true;
  68.             nullOffsetRatioX = 0.25f;
  69.             mapOffsetX = 6f;
  70.             mapOffsetY = 0f;
  71.             mapPoolMessage[0] = (qty) => "x " + qty.ToString();
  72.             mapPoolMessage[1] = (qty) => "x " + qty.ToString();
  73.             Font_Pool[0] = Hud.Render.CreateFont("Arial", 7f, 255, 255, 255, 51, true, false, 160, 51, 51, 51, true);
  74.             Font_Pool[1] = Hud.Render.CreateFont("Arial", 7f, 255, 255, 51, 51, true, false, 160, 51, 51, 51, true);
  75.  
  76.             skipPoolDecorator = false; // show pool Decorator in Map or not
  77.             showInDistance[0] = 5000f; // show Decorator if distance is less than this value, 0 notUsed 1 used
  78.             showInDistance[1] = 150f;
  79.             PoolDecorator[0] = new WorldDecoratorCollection(
  80.                 new MapShapeDecorator(Hud) {
  81.                     Brush = Hud.Render.CreateBrush(255, 255, 255, 51, -1),
  82.                     ShapePainter = new LineFromMeShapePainter(Hud)
  83.                 },
  84.                 new MapTextureDecorator(Hud) {
  85.                     Texture = Hud.Texture.GetTexture(376779, 0),
  86.                     Radius = 1f,
  87.                 },
  88.                 new MapShapeDecorator(Hud) {
  89.                     Brush = Hud.Render.CreateBrush(255, 255, 255, 51, -1),
  90.                     Radius = 15f,
  91.                     ShapePainter = new RectangleShapePainter(Hud),
  92.                 }
  93.             );
  94.  
  95.             PoolDecorator[1] = new WorldDecoratorCollection(
  96.                 new MapShapeDecorator(Hud) {
  97.                     Brush = Hud.Render.CreateBrush(255, 255, 255, 51, -1),
  98.                     Radius = 15f,
  99.                     ShapePainter = new CircleShapePainter(Hud),
  100.                 }
  101.             );
  102.  
  103.             poolTexture[0] = Hud.Texture.GetTexture(376779, 0);
  104.             poolTexture[1] = Hud.Texture.GetTexture(384218, 0);
  105.             if (!resetWayPoint) {
  106.                 wayPointList.Add(new DAV_WayPointSno(1, 91133, 1999831045, Hud.Window.CreateWorldCoordinate(1976.710f, 2788.146f, 41.2f)));
  107.                 wayPointList.Add(new DAV_WayPointSno(1, 19780, 1999962119, Hud.Window.CreateWorldCoordinate(820.000f, 749.307f, 0.0f)));
  108.                 wayPointList.Add(new DAV_WayPointSno(1, 19783, 2000027656, Hud.Window.CreateWorldCoordinate(820.000f, 701.500f, 0.0f)));
  109.                 wayPointList.Add(new DAV_WayPointSno(1, 19785, 2000093193, Hud.Window.CreateWorldCoordinate(820.000f, 1229.307f, 0.0f)));
  110.                 wayPointList.Add(new DAV_WayPointSno(1, 19787, 2000158730, Hud.Window.CreateWorldCoordinate(1059.357f, 578.648f, 0.0f)));
  111.                 wayPointList.Add(new DAV_WayPointSno(1, 19954, 1999831045, Hud.Window.CreateWorldCoordinate(2895.395f, 2371.276f, 0.0f)));
  112.                 wayPointList.Add(new DAV_WayPointSno(1, 72712, 1999831045, Hud.Window.CreateWorldCoordinate(2161.802f, 1826.882f, 1.9f)));
  113.                 wayPointList.Add(new DAV_WayPointSno(1, 19952, 1999831045, Hud.Window.CreateWorldCoordinate(2037.839f, 910.656f, 1.9f)));
  114.                 wayPointList.Add(new DAV_WayPointSno(1, 61573, 1999831045, Hud.Window.CreateWorldCoordinate(1263.054f, 827.765f, 63.1f)));
  115.                 wayPointList.Add(new DAV_WayPointSno(1, 19953, 1999831045, Hud.Window.CreateWorldCoordinate(423.106f, 781.156f, 21.2f)));
  116.                 wayPointList.Add(new DAV_WayPointSno(1, 93632, 1999831045, Hud.Window.CreateWorldCoordinate(2310.500f, 4770.000f, 1.0f)));
  117.                 wayPointList.Add(new DAV_WayPointSno(1, 78572, 2000617489, Hud.Window.CreateWorldCoordinate(1339.771f, 1159.466f, 0.0f)));
  118.                 wayPointList.Add(new DAV_WayPointSno(1, 19941, 1999831045, Hud.Window.CreateWorldCoordinate(1688.828f, 3890.089f, 41.9f)));
  119.                 wayPointList.Add(new DAV_WayPointSno(1, 19943, 1999831045, Hud.Window.CreateWorldCoordinate(1080.022f, 3444.448f, 62.4f)));
  120.                 wayPointList.Add(new DAV_WayPointSno(1, 19774, 2000814100, Hud.Window.CreateWorldCoordinate(820.000f, 736.500f, 0.0f)));
  121.                 wayPointList.Add(new DAV_WayPointSno(1, 119870, 2001207322, Hud.Window.CreateWorldCoordinate(56.772f, 146.284f, 0.0f)));
  122.                 wayPointList.Add(new DAV_WayPointSno(1, 19775, 2000879637, Hud.Window.CreateWorldCoordinate(452.500f, 820.000f, 0.0f)));
  123.                 wayPointList.Add(new DAV_WayPointSno(1, 19776, 2000945174, Hud.Window.CreateWorldCoordinate(979.000f, 1060.000f, 0.0f)));
  124.  
  125.                 wayPointList.Add(new DAV_WayPointSno(2, 19836, 2001272859, Hud.Window.CreateWorldCoordinate(2760.302f, 1631.820f, 187.5f)));
  126.                 wayPointList.Add(new DAV_WayPointSno(2, 63666, 2001272859, Hud.Window.CreateWorldCoordinate(1419.449f, 321.863f, 176.3f)));
  127.                 wayPointList.Add(new DAV_WayPointSno(2, 19835, 2001272859, Hud.Window.CreateWorldCoordinate(1427.769f, 1185.675f, 186.2f)));
  128.                 wayPointList.Add(new DAV_WayPointSno(2, 460671, 2001403933, Hud.Window.CreateWorldCoordinate(1747.454f, 549.045f, 0.5f)));
  129.                 wayPointList.Add(new DAV_WayPointSno(2, 456638, 2001469470, Hud.Window.CreateWorldCoordinate(400.119f, 889.819f, 0.2f)));
  130.                 wayPointList.Add(new DAV_WayPointSno(2, 210451, 2001600544, Hud.Window.CreateWorldCoordinate(612.485f, 936.556f, -29.8f)));
  131.                 wayPointList.Add(new DAV_WayPointSno(2, 57425, 2001272859, Hud.Window.CreateWorldCoordinate(3548.838f, 4269.278f, 101.9f)));
  132.                 wayPointList.Add(new DAV_WayPointSno(2, 62752, 2001797155, Hud.Window.CreateWorldCoordinate(90.000f, 59.500f, 2.7f)));
  133.                 wayPointList.Add(new DAV_WayPointSno(2, 53834, 2001272859, Hud.Window.CreateWorldCoordinate(1257.886f, 3968.300f, 111.8f)));
  134.                 wayPointList.Add(new DAV_WayPointSno(2, 19800, 2002124840, Hud.Window.CreateWorldCoordinate(799.995f, 680.024f, -0.1f)));
  135.  
  136.                 wayPointList.Add(new DAV_WayPointSno(3, 75436, 1999568897, Hud.Window.CreateWorldCoordinate(1065.148f, 472.449f, 0.0f)));
  137.                 wayPointList.Add(new DAV_WayPointSno(3, 93103, 2002321451, Hud.Window.CreateWorldCoordinate(825.148f, 1192.449f, 0.0f)));
  138.                 wayPointList.Add(new DAV_WayPointSno(3, 136448, 2002386988, Hud.Window.CreateWorldCoordinate(825.148f, 472.449f, 0.0f)));
  139.                 wayPointList.Add(new DAV_WayPointSno(3, 93173, 2002452525, Hud.Window.CreateWorldCoordinate(4272.158f, 4252.097f, -24.8f)));
  140.                 wayPointList.Add(new DAV_WayPointSno(3, 154644, 1999699971, Hud.Window.CreateWorldCoordinate(4356.238f, 408.241f, -2.9f)));
  141.                 wayPointList.Add(new DAV_WayPointSno(3, 155048, 1999699971, Hud.Window.CreateWorldCoordinate(3452.838f, 609.227f, 0.2f)));
  142.                 wayPointList.Add(new DAV_WayPointSno(3, 69504, 1999699971, Hud.Window.CreateWorldCoordinate(2708.557f, 586.267f, 0.0f)));
  143.                 wayPointList.Add(new DAV_WayPointSno(3, 86080, 2002583599, Hud.Window.CreateWorldCoordinate(1679.054f, 744.707f, 0.0f)));
  144.                 wayPointList.Add(new DAV_WayPointSno(3, 80791, 2002714673, Hud.Window.CreateWorldCoordinate(1041.245f, 983.039f, -10.0f)));
  145.                 wayPointList.Add(new DAV_WayPointSno(3, 119305, 2002845747, Hud.Window.CreateWorldCoordinate(2573.769f, 1206.666f, 0.0f)));
  146.                 wayPointList.Add(new DAV_WayPointSno(3, 119653, 2002976821, Hud.Window.CreateWorldCoordinate(959.404f, 1097.913f, -10.0f)));
  147.                 wayPointList.Add(new DAV_WayPointSno(3, 119306, 2003107895, Hud.Window.CreateWorldCoordinate(1162.255f, 686.218f, 0.0f)));
  148.                 wayPointList.Add(new DAV_WayPointSno(3, 428494, 2003238969, Hud.Window.CreateWorldCoordinate(606.110f, 1065.332f, 0.0f)));
  149.  
  150.                 wayPointList.Add(new DAV_WayPointSno(4, 109526, 2003435580, Hud.Window.CreateWorldCoordinate(1073.872f, 786.390f, 0.0f)));
  151.                 wayPointList.Add(new DAV_WayPointSno(4, 464857, 2003501117, Hud.Window.CreateWorldCoordinate(1340.086f, 110.277f, 0.0f)));
  152.                 wayPointList.Add(new DAV_WayPointSno(4, 409001, 2003566654, Hud.Window.CreateWorldCoordinate(1339.833f, 359.946f, -1.3f)));
  153.                 wayPointList.Add(new DAV_WayPointSno(4, 464065, 2003697728, Hud.Window.CreateWorldCoordinate(1030.028f, 870.214f, 15.0f)));
  154.                 wayPointList.Add(new DAV_WayPointSno(4, 409512, 2003632191, Hud.Window.CreateWorldCoordinate(2072.500f, 2747.500f, -30.0f)));
  155.                 wayPointList.Add(new DAV_WayPointSno(4, 109514, 2003763265, Hud.Window.CreateWorldCoordinate(873.785f, 1114.032f, -14.9f)));
  156.                 wayPointList.Add(new DAV_WayPointSno(4, 409517, 2003828802, Hud.Window.CreateWorldCoordinate(2520.398f, 1979.950f, 15.0f)));
  157.                 wayPointList.Add(new DAV_WayPointSno(4, 109538, 2003894339, Hud.Window.CreateWorldCoordinate(1079.837f, 856.173f, -1.3f)));
  158.                 wayPointList.Add(new DAV_WayPointSno(4, 109540, 2004090950, Hud.Window.CreateWorldCoordinate(345.398f, 359.990f, -1.3f)));
  159.                 wayPointList.Add(new DAV_WayPointSno(4, 464066, 2004222024, Hud.Window.CreateWorldCoordinate(2500.083f, 1390.092f, 31.0f)));
  160.                 wayPointList.Add(new DAV_WayPointSno(4, 475856, 2004222024, Hud.Window.CreateWorldCoordinate(348.659f, 341.491f, 50.8f)));
  161.                 wayPointList.Add(new DAV_WayPointSno(4, 475854, 2004287561, Hud.Window.CreateWorldCoordinate(1559.163f, 3636.186f, -23.3f)));
  162.                 wayPointList.Add(new DAV_WayPointSno(4, 464063, 2004287561, Hud.Window.CreateWorldCoordinate(350.023f, 350.276f, 0.0f)));
  163.  
  164.                 wayPointList.Add(new DAV_WayPointSno(5, 263493, 2004353098, Hud.Window.CreateWorldCoordinate(1026.961f, 418.969f, 10.8f)));
  165.                 wayPointList.Add(new DAV_WayPointSno(5, 338946, 2004484172, Hud.Window.CreateWorldCoordinate(1260.250f, 540.750f, 3.3f)));
  166.                 wayPointList.Add(new DAV_WayPointSno(5, 261758, 2004549709, Hud.Window.CreateWorldCoordinate(402.102f, 419.735f, 10.3f)));
  167.                 wayPointList.Add(new DAV_WayPointSno(5, 283553, 2004680783, Hud.Window.CreateWorldCoordinate(608.812f, 417.468f, 0.0f)));
  168.                 wayPointList.Add(new DAV_WayPointSno(5, 258142, 2004746320, Hud.Window.CreateWorldCoordinate(1140.714f, 540.347f, 12.4f)));
  169.                 wayPointList.Add(new DAV_WayPointSno(5, 283567, 2004877394, Hud.Window.CreateWorldCoordinate(877.314f, 399.194f, 0.0f)));
  170.                 wayPointList.Add(new DAV_WayPointSno(5, 338602, 2004942931, Hud.Window.CreateWorldCoordinate(1433.629f, 220.720f, 0.3f)));
  171.                 wayPointList.Add(new DAV_WayPointSno(5, 271234, 2005139542, Hud.Window.CreateWorldCoordinate(1069.580f, 679.856f, 20.2f)));
  172.                 wayPointList.Add(new DAV_WayPointSno(5, 459863, 2005205079, Hud.Window.CreateWorldCoordinate(1000.500f, 1160.500f, 0.5f)));
  173.                 wayPointList.Add(new DAV_WayPointSno(5, 427763, 2005270616, Hud.Window.CreateWorldCoordinate(661.430f, 423.897f, 2.9f)));
  174.             }
  175.         }
  176.  
  177.         public void OnNewArea(bool newGame, ISnoArea area) {
  178.             if (newGame) {
  179.                 if (resetWayPoint)
  180.                     wayPointList.Clear();
  181.  
  182.                 showSummary = false;
  183.                 PoolMarkers.Clear();
  184.                 lastWayPointSno = 0;
  185.                 poolTotal = 0;
  186.                 for (var i = 0; i < 6; i++) {
  187.                     poolFind[i] = 0;
  188.                     poolUsed[i] = 0;
  189.                 }
  190.                 return;
  191.             }
  192.  
  193.             if (area.IsTown) {
  194.                 lastAct = 0;
  195.                 lastWayPointSno = 0;
  196.             }
  197.         }
  198.  
  199.         public void AfterCollect() {
  200.             // Scene data update with a higher priority
  201.             if (Hud.Game.Me.Scene == null || Hud.Game.Me.Scene.SnoArea == null) return;
  202.             if (Hud.Game.Me.Scene.SnoArea.IsTown) return;
  203.  
  204.             var act = Hud.Game.Me.Scene.SnoArea.ActFixed();
  205.             var newWayPoint = Hud.Game.Actors.FirstOrDefault(x => x.SnoActor.Sno == ActorSnoEnum._waypoint || x.SnoActor.Sno == ActorSnoEnum._a4_heaven_waypoint || x.SnoActor.Sno == ActorSnoEnum._waypoint_oldtristram);
  206.             if (newWayPoint != null && newWayPoint.Scene != null) {
  207.                 lastAct = act; //newWayPoint.Scene.SnoArea.ActFixed();
  208.                 lastWayPointSno = newWayPoint.Scene.SnoArea.Sno;
  209.                 switch(lastWayPointSno) { // Adjust for SceneSnoArea, W.T.F. not match with the waypoint TargetSnoArea
  210.                     case 101351 : lastWayPointSno = 91133; break;
  211.                     case 19952 :
  212.                         if (newWayPoint.FloorCoordinate.XYDistanceTo(1263.054f, 827.765f) < 30)
  213.                             lastWayPointSno = 61573;
  214.                         break;
  215.                     case 19839 : lastWayPointSno = 19835; break;
  216.                     case 112565 : lastWayPointSno = 69504; break;
  217.                 }
  218.  
  219.                 // save Way Point (works only if resetWayPoint = true)
  220.                 if (resetWayPoint && lastWayPointSno > 0 && !wayPointList.Any(x => x.AreaSno == lastWayPointSno)) {
  221.                     wayPointList.Add(new DAV_WayPointSno(act, lastWayPointSno, newWayPoint.WorldId, newWayPoint.FloorCoordinate));
  222.                     foreach (var key in PoolMarkers.Keys.ToList()) {
  223.                         var pool = PoolMarkers[key];
  224.                         if (pool.WorldId != newWayPoint.WorldId) continue;
  225.  
  226.                         var revDist = newWayPoint.FloorCoordinate.XYDistanceTo(pool.FloorCoordinate);
  227.                         if (revDist < pool.distance) {
  228.                             pool.distance = revDist;
  229.                             pool.AreaName = nearWayPointName;
  230.                             pool.nearWayPointSno = lastWayPointSno;
  231.                         }
  232.                     }
  233.                 }
  234.             }
  235.  
  236.             foreach (var marker in Hud.Game.Markers.Where(x => x.IsPoolOfReflection)) {
  237.                 if (PoolMarkers.ContainsKey(marker.Id)) {
  238.                     if (marker.IsUsed != PoolMarkers[marker.Id].IsUsed) {
  239.                         PoolMarkers[marker.Id].IsUsed = marker.IsUsed;
  240.                         poolUsed[act]++;
  241.                         poolTotal--;
  242.                         UpdateSummary();
  243.                     }
  244.                     continue;
  245.                 }
  246.  
  247.                 var dist = float.MaxValue;
  248.                 var useAreaSno = act == lastAct ? lastWayPointSno : 0; // adjust if teleport to others in different act
  249.                 var mapName = Hud.Game.Me.Scene.SnoArea.NameLocalized;
  250.                 if (string.IsNullOrEmpty(mapName)) return;
  251.  
  252.                 foreach(var waypoint in wayPointList.Where(x => x.WorldId == marker.WorldId)) {
  253.                     var thisDist = waypoint.FloorCoordinate.XYDistanceTo(marker.FloorCoordinate);
  254.                     if (thisDist < dist) {
  255.                         dist = thisDist;
  256.                         mapName = nearWayPointName;
  257.                         useAreaSno = waypoint.AreaSno;
  258.                     }
  259.                 }
  260.  
  261.                 PoolMarkers.Add(marker.Id, new DAV_PoolInfo(marker, act, useAreaSno, mapName, dist));
  262.                 poolFind[act]++;
  263.                 poolTotal++;
  264.                 if (marker.IsUsed) {
  265.                     poolUsed[act]++;
  266.                     poolTotal--;
  267.                 }
  268.                 UpdateSummary();
  269.             }
  270.         }
  271.  
  272.         public void OnKeyEvent(IKeyEvent keyEvent) {
  273.             if (keyEvent.IsPressed && keyEvent.Key == Key)
  274.                 showSummary = !showSummary;
  275.         }
  276.  
  277.         public void PaintWorld(WorldLayer layer) {
  278.             if (skipPoolDecorator) return;
  279.             if (Hud.Game.IsInTown) return;
  280.             if (Hud.Game.SpecialArea == SpecialArea.GreaterRift) return;
  281.  
  282.             foreach (var pool in Hud.Game.Markers.Where(x => x.IsPoolOfReflection)) {
  283.                 var i = pool.IsUsed ? 1 : 0;
  284.                 var range = Hud.Game.Me.FloorCoordinate.XYDistanceTo(pool.FloorCoordinate);
  285.  
  286.                 if (range < showInDistance[i])
  287.                     PoolDecorator[i].Paint(layer, null, pool.FloorCoordinate, null);
  288.             }
  289.         }
  290.  
  291.         public void PaintTopInGame(ClipState clipState) {
  292.             if (PoolMarkers.Count == 0) return;
  293.             if (clipState != ClipState.AfterClip) return;
  294.             if (Hud.Game.SpecialArea != SpecialArea.None) return;
  295.  
  296.             poolTexture[poolTotal > 0 ? 0 : 1].Draw(xPos - 0.76f * iconSize, yPos - 0.25f * iconSize, iconSize, iconSize);
  297.             if ((showAlways || showSummary) && !string.IsNullOrEmpty(summaryMessage))
  298.                 Font_Pool_Summary.DrawText(summaryMessage, xPos, yPos);
  299.  
  300.             if (!Hud.Render.WorldMapUiElement.Visible || Hud.Render.ActMapUiElement.Visible) return;
  301.  
  302.             var mapCurrentAct = Hud.Game.ActMapCurrentAct;
  303.             var rect = Hud.Render.WorldMapUiElement.Rectangle;
  304.             var poolList = PoolMarkers.Values.ToList();
  305.             foreach (var waypoint in Hud.Game.ActMapWaypoints.Where(z => z.BountyAct == mapCurrentAct && !z.TargetSnoArea.IsTown)) {
  306.                 var thisList = poolList.Where(z => z.nearWayPointSno == waypoint.TargetSnoArea.Sno);
  307.                 if (thisList.Count() == 0) continue;
  308.  
  309.                 var xref = rect.X + Hud.Window.HeightUiRatio * (waypoint.CoordinateOnMapUiElement.X + 110);
  310.                 var yref = rect.Y + Hud.Window.HeightUiRatio * waypoint.CoordinateOnMapUiElement.Y + mapOffsetY;
  311.                 PaintPoolNumber(thisList, xref, yref, showMapName);
  312.             }
  313.  
  314.             var currentAct = ((int)mapCurrentAct) / 100 + 1;
  315.             var nullList = poolList.Where(z => z.Act == 0 || (z.Act == currentAct && z.nearWayPointSno == 0));
  316.             if (nullList.Count() > 0)
  317.                 PaintPoolNumber(nullList, rect.X + rect.Width * nullOffsetRatioX, rect.Y + 110 * Hud.Window.HeightUiRatio);
  318.         }
  319.  
  320.         private void PaintPoolNumber(IEnumerable<DAV_PoolInfo> poolList, float xref, float yref, bool showName = true) {
  321.             int[] qty = { 0, 0 };
  322.             string[] location = { " : ", " : " };
  323.             foreach (var pool in poolList) {
  324.                 var i = pool.IsUsed ? 1 : 0;
  325.                 qty[i]++;
  326.                 if (showName && !location[i].Contains(pool.AreaName))
  327.                     location[i] += "<" + pool.AreaName + ">";
  328.             }
  329.  
  330.             if (qty[0] > 0)
  331.                 Font_Pool[0].DrawText(mapPoolMessage[0](qty[0]) + (showName ? location[0] : ""), xref + mapOffsetX, yref);
  332.             if (qty[1] > 0) {
  333.                 var layout = Font_Pool[1].GetTextLayout(mapPoolMessage[1](qty[1]) + (showName ? location[1] : ""));
  334.                 Font_Pool[1].DrawText(layout, xref - layout.Metrics.Width - mapOffsetX, yref);
  335.             }
  336.         }
  337.  
  338.         private void UpdateSummary() {
  339.             summaryMessage = "";
  340.             for (var i = 0; i < 6; i++) {
  341.                 var curPool = poolFind[i] - poolUsed[i];
  342.                 if (curPool > 0 || (showALLPool && poolFind[i] > 0))
  343.                     summaryMessage += PoolSumMessage(i, curPool, poolFind[i]) + "\n";
  344.             }
  345.  
  346.             if (!string.IsNullOrEmpty(summaryMessage))
  347.                 summaryMessage = PoolSumHeader + "\n" + summaryMessage;
  348.         }
  349.     }
  350.  
  351.     public class DAV_WayPointSno {
  352.         public int Act { get; set; }
  353.         public uint AreaSno { get; set; }
  354.         public uint WorldId { get; set; }
  355.         public IWorldCoordinate FloorCoordinate { get; set; }
  356.  
  357.         public DAV_WayPointSno(int act, uint areaSno, uint worldId, IWorldCoordinate mapCoord) {
  358.             Act = act;
  359.             AreaSno = areaSno;
  360.             WorldId = worldId;
  361.             FloorCoordinate = mapCoord;
  362.         }
  363.     }
  364.  
  365.     public class DAV_PoolInfo {
  366.         public int Act { get; set; }
  367.         public bool IsUsed { get; set; }
  368.         public uint WorldId { get; set; }
  369.         public string uniqueID { get; set; }
  370.         public IWorldCoordinate FloorCoordinate { get; set; }
  371.  
  372.         public string AreaName { get; set; }
  373.         public uint nearWayPointSno { get; set; }
  374.         public float distance { get; set; }
  375.  
  376.         public DAV_PoolInfo(IMarker pMarker, int act, uint areaSno, string name, float dist) {
  377.             Act = act;
  378.             IsUsed = pMarker.IsUsed;
  379.             WorldId = pMarker.WorldId;
  380.             uniqueID = pMarker.Id;
  381.             FloorCoordinate = pMarker.FloorCoordinate;
  382.  
  383.             AreaName = name;
  384.             distance = dist;
  385.             nearWayPointSno = areaSno;
  386.         }
  387.     }
  388. }
Advertisement
Add Comment
Please, Sign In to add comment