-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEssenceCorruptionHelper.cs
135 lines (119 loc) · 4.4 KB
/
EssenceCorruptionHelper.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
using System.Diagnostics;
using System.Drawing;
using ExileCore;
using ExileCore.PoEMemory.Components;
using ExileCore.PoEMemory.Elements;
using ExileCore.PoEMemory.MemoryObjects;
using ExileCore.Shared.Enums;
using ExileCore.Shared.Helpers;
using SharpDX;
using static System.Net.Mime.MediaTypeNames;
using Color = SharpDX.Color;
using RectangleF = SharpDX.RectangleF;
using Vector2 = System.Numerics.Vector2;
namespace EssenceCorruptionHelper;
public class EssenceCorruptionHelper : BaseSettingsPlugin<Settings>
{
private IngameState ingameState;
public override bool Initialise()
{
Graphics.InitImage("Plugins\\Compiled\\EssenceCorruptionHelper\\corruption.png", false);
ingameState = GameController.Game.IngameState;
Name = "Essence Corruption Helper";
return base.Initialise();
}
public override void Render()
{
if (!Settings.Enable) return;
Draw();
}
bool assessAlreadyCorrupted() {
return GameController.IngameState.IngameUi.ItemsOnGroundLabelsVisible
.Where(x => x.ItemOnGround.Path == "Metadata/MiscellaneousObjects/Monolith")
.First().Label.Children[1].Children
.Select(x => x.Text)
.Any(text => {
if (string.IsNullOrEmpty(text)) return false;
return text.Contains("Remnant of Corruption");
});
}
bool BoolMonolithHasMeds()
{
if (assessAlreadyCorrupted()) {
return false;
}
return GameController.IngameState.IngameUi.ItemsOnGroundLabelsVisible
.Where(x => x.ItemOnGround.Path == "Metadata/MiscellaneousObjects/Monolith")
.First().Label.Children[1].Children
.Select(x => x.Text)
// Returns true if any of the properties text
.Any(text =>
{
if (string.IsNullOrEmpty(text)) return false;
if (text.Contains("Misery"))
{
return true;
}
if (text.Contains("Envy"))
{
return true;
}
if (text.Contains("Dread"))
{
return true;
}
if (text.Contains("Scorn"))
{
return true;
}
// No matches, return false
return false;
});
}
private bool BoolMonolithHasAmountOfEssence() {
if (assessAlreadyCorrupted()) {
return false;
}
return GameController.IngameState.IngameUi.ItemsOnGroundLabelsVisible
.Where(x => x.ItemOnGround.Path == "Metadata/MiscellaneousObjects/Monolith")
.First().Label.Children[1].Children.Count() - 4 >= Settings.AmountOfEssence;
}
private void DrawTextAndImage(Vector2 position)
{
using (Graphics.SetTextScale(Settings.TextSize))
{
Graphics.DrawText("Corrupt me", position, Color.Red, FontAlign.Center);
}
Graphics.DrawImage("corruption.png", new RectangleF(position.X - 25, position.Y - 125, 64, 63));
}
private void Draw()
{
var camera = ingameState.Camera;
var entities = GameController.Entities
.Where(entity => entity.HasComponent<Render>() &&
entity.Address != GameController.Player.Address &&
entity.IsValid &&
entity.IsTargetable &&
entity.HasComponent<Monolith>());
foreach (var entity in entities)
{
var entityPos = entity.PosNum;
var entityScreenPos = camera.WorldToScreen(entityPos.Translate(0, 0, 0));
if (Settings.ToggleMeds)
{
//highlight MEDS Shrine
if (BoolMonolithHasMeds())
{
DrawTextAndImage(entityScreenPos);
}
}
if (Settings.ToggleAmount)
{
if(BoolMonolithHasAmountOfEssence())
{
DrawTextAndImage(entityScreenPos);
}
}
}
}
}