-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathCustomItem.cs
196 lines (173 loc) · 7.02 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
using System;
using System.Collections.Generic;
using System.Linq;
using ExileCore;
using ExileCore.PoEMemory;
using ExileCore.PoEMemory.Components;
using ExileCore.PoEMemory.Elements;
using ExileCore.PoEMemory.MemoryObjects;
using ExileCore.Shared.Enums;
using Map = ExileCore.PoEMemory.Components.Map;
namespace PickIt
{
public class CustomItem
{
public Func<bool> IsTargeted;
public bool IsValid;
public CustomItem(LabelOnGround item, FilesContainer fs, float distance, Dictionary<string, int> weightsRules, bool isMetamorphItem = false)
{
if (isMetamorphItem)
{
IsMetaItem = true;
LabelOnGround = item;
Distance = distance;
var itemItemOnGround = item.ItemOnGround;
var worldIcon = itemItemOnGround?.GetComponent<MinimapIcon>();
if (worldIcon == null) return;
//var groundItem = worldItem.ItemEntity;
WorldIcon = worldIcon;
GroundItem = itemItemOnGround;
Path = GroundItem?.Path;
if (Path != null && Path.Length < 1)
{
DebugWindow.LogMsg($"World2: {worldIcon.Address:X} P: {Path}", 2);
DebugWindow.LogMsg($"Ground2: {GroundItem.Address:X} P {Path}", 2);
return;
}
IsTargeted = () =>
{
var isTargeted = itemItemOnGround.GetComponent<Targetable>()?.isTargeted;
return isTargeted != null && (bool)isTargeted;
};
var baseItemType = fs.BaseItemTypes.Translate(Path);
if (baseItemType != null)
{
ClassName = baseItemType.ClassName;
BaseName = baseItemType.BaseName;
Width = baseItemType.Width;
Height = baseItemType.Height;
if (weightsRules.TryGetValue(BaseName, out var w)) Weight = w;
if (ClassName.StartsWith("Heist")) IsHeist = true;
}
IsValid = true;
}
else
{
isMetamorphItem = false;
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;
if (weightsRules.TryGetValue(BaseName, out var w)) Weight = w;
if (ClassName.StartsWith("Heist")) IsHeist = true;
}
var WeaponClass = new List<string>
{
"One Hand Mace",
"Two Hand Mace",
"One Hand Axe",
"Two Hand Axe",
"One Hand Sword",
"Two Hand Sword",
"Thrusting One Hand Sword",
"Bow",
"Claw",
"Dagger",
"Rune Dagger",
"Sceptre",
"Staff",
"Wand"
};
if (GroundItem.HasComponent<Quality>())
{
var quality = GroundItem.GetComponent<Quality>();
Quality = quality.ItemQuality;
}
if (GroundItem.HasComponent<Base>())
{
var @base = GroundItem.GetComponent<Base>();
IsElder = @base.isElder;
IsShaper = @base.isShaper;
IsHunter = @base.isHunter;
IsRedeemer = @base.isRedeemer;
IsCrusader = @base.isCrusader;
IsWarlord = @base.isWarlord;
}
if (GroundItem.HasComponent<Mods>())
{
var mods = GroundItem.GetComponent<Mods>();
Rarity = mods.ItemRarity;
IsIdentified = mods.Identified;
ItemLevel = mods.ItemLevel;
IsFractured = mods.HaveFractured;
IsVeiled = mods.ItemMods.Any(m => m.DisplayName.Contains("Veil"));
}
if (GroundItem.HasComponent<Sockets>())
{
var sockets = GroundItem.GetComponent<Sockets>();
IsRGB = sockets.IsRGB;
Sockets = sockets.NumberOfSockets;
LargestLink = sockets.LargestLinkSize;
}
if (GroundItem.HasComponent<Weapon>())
{
IsWeapon = true;
}
MapTier = GroundItem.HasComponent<Map>() ? GroundItem.GetComponent<Map>().Tier : 0;
IsValid = true;
}
}
public string BaseName { get; } = "";
public string ClassName { get; } = "";
public LabelOnGround LabelOnGround { get; }
public float Distance { get; }
public Entity GroundItem { get; }
public MinimapIcon WorldIcon { get;}
public int Height { get; }
public bool IsElder { get; }
public bool IsIdentified { get; }
public bool IsRGB { get; }
public bool IsShaper { get; }
public bool IsHunter { get; }
public bool IsRedeemer { get; }
public bool IsCrusader { get; }
public bool IsWarlord { get; }
public bool IsHeist { get; }
public bool IsVeiled { get; }
public bool IsWeapon { get; }
public int ItemLevel { get; }
public int LargestLink { get; }
public int MapTier { get; }
public string Path { get; }
public int Quality { get; }
public ItemRarity Rarity { get; }
public int Sockets { get; }
public int Width { get; }
public bool IsFractured { get; }
public int Weight { get; set; }
public bool IsMetaItem { get; set; }
public override string ToString()
{
return $"{BaseName} ({ClassName}) W: {Weight} Dist: {Distance}";
}
}
}