This repository was archived by the owner on Dec 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathUniqueLootHelperCore.cs
More file actions
77 lines (72 loc) · 2.71 KB
/
UniqueLootHelperCore.cs
File metadata and controls
77 lines (72 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
using ExileCore;
using ExileCore.PoEMemory.Components;
using System.Collections.Generic;
using System.Linq;
using System.IO;
namespace UniqueLootHelper
{
public class UniqueLootHelperCore : BaseSettingsPlugin<Settings>
{
private const string UNIQUESARTWORK_FILE = "UniquesArtworks.txt";
private HashSet<string> UniquesHashSet;
public List<SharpDX.RectangleF> drawingList = new List<SharpDX.RectangleF>();
public override bool Initialise()
{
Name = "UniqueLootHelper";
Settings.RefreshUniquesFile.OnPressed += () => { ReadUniquesArtworkFile(); };
ReadUniquesArtworkFile();
return base.Initialise();
}
private void ReadUniquesArtworkFile()
{
var path = $"{DirectoryFullName}\\{UNIQUESARTWORK_FILE}";
if (File.Exists(path))
{
UniquesHashSet = File.ReadAllLines(path).Where(line => !string.IsNullOrWhiteSpace(line) && !line.StartsWith("#")).ToList().Select(x => x + ".dds").ToHashSet();
}
else
CreateUniquesArtworkFile();
}
private void CreateUniquesArtworkFile()
{
var path = $"{DirectoryFullName}\\{UNIQUESARTWORK_FILE}";
if (File.Exists(path)) return;
using (var streamWriter = new StreamWriter(path, true))
{
streamWriter.Write("");
streamWriter.Close();
}
}
public override void Render()
{
foreach (var frame in drawingList)
{
Graphics.DrawFrame(frame, Settings.Color, Settings.FrameThickness);
}
}
public override Job Tick()
{
drawingList.Clear();
if (GameController.Area.CurrentArea.IsHideout ||
GameController.Area.CurrentArea.IsTown)
{
return null;
}
foreach (var label in GameController.IngameState.IngameUi.ItemsOnGroundLabelsVisible)
{
var worlditem = label.ItemOnGround.GetComponent<WorldItem>();
if (worlditem == null) continue;
if (worlditem.ItemEntity.Type != ExileCore.Shared.Enums.EntityType.Item) continue;
var renderitem = worlditem.ItemEntity.GetComponent<RenderItem>();
if (renderitem == null) continue;
var modelPath = renderitem.ResourcePath;
if (modelPath == null) continue;
if (UniquesHashSet.Contains(modelPath))
{
drawingList.Add(label.Label.GetClientRectCache);
}
}
return null;
}
}
}