forked from Arecurius0/ClickIt
-
Notifications
You must be signed in to change notification settings - Fork 4
/
CustomItem.cs
68 lines (60 loc) · 2.03 KB
/
CustomItem.cs
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
using ExileCore;
using ExileCore.PoEMemory;
using ExileCore.PoEMemory.Components;
using ExileCore.PoEMemory.Elements;
using ExileCore.PoEMemory.MemoryObjects;
using System;
namespace ClickIt
{
public class CustomItem
{
public Func<bool> IsTargeted;
public bool IsValid;
public string BaseName { get; } = "";
public string ClassName { get; } = "";
public LabelOnGround LabelOnGround { get; }
public float Distance { get; }
public Entity GroundItem { get; }
public int Height { get; }
public string Path { get; }
public int Width { get; }
public CustomItem(LabelOnGround item, FilesContainer fs)
{
LabelOnGround = item;
//Distance = distance;
var itemItemOnGround = item.ItemOnGround;
var worldItem = itemItemOnGround?.GetComponent<WorldItem>();
if (worldItem == null)
{
return;
}
var groundItem = worldItem.ItemEntity;
GroundItem = groundItem;
Path = groundItem?.Path;
if (GroundItem == null)
{
return;
}
if (Path != null && Path.Length < 1)
{
DebugWindow.LogMsg($"World: {worldItem.Address:X} P: {Path}", 2);
DebugWindow.LogMsg($"Ground: {GroundItem.Address:X} P {Path}", 2);
return;
}
IsTargeted = () => itemItemOnGround?.GetComponent<Targetable>()?.isTargeted == true;
var baseItemType = fs.BaseItemTypes.Translate(Path);
if (baseItemType != null)
{
ClassName = baseItemType.ClassName;
BaseName = baseItemType.BaseName;
Width = baseItemType.Width;
Height = baseItemType.Height;
}
IsValid = true;
}
public override string ToString()
{
return $"{BaseName} ({ClassName}) Dist: {GroundItem.DistancePlayer}";
}
}
}