-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMinimap.cs
176 lines (156 loc) · 6.43 KB
/
Minimap.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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using ExternalRPM.Data;
using ExternalRPM.Model;
using ExternalRPM.Model.Kindred;
using ExternalRPM.Modules;
using SharpDX;
using SharpDX.Direct3D9;
using Color = SharpDX.Color;
namespace ExternalRPM
{
/*
Description:
This class handles the rendering and drawing of the in-game minimap and related elements, such as markers for jungle camps,
respawn timers, and Kindred's mark respawn timer.
Public Methods:
- DrawMinimapOverlay(): Draws the overlay of the minimap on the screen.
- DrawMarkerOnMinimap(): Draws markers on the minimap for jungle camps.
- DrawRespawntimerOnMap(): Draws the remaining respawn time for jungle camps on the minimap.
- DrawKindredMarkRespawnTimer(): Draws the remaining time for Kindred's mark respawn timer on the screen.
- WorldToMap(float posX, float posY): Converts world coordinates to minimap coordinates.
Private Methods:
- getWorldSize(): Gets the world size from the game's memory.
- getMinimapSize(): Gets the minimap size from the game's memory.
- getScaleFactor(): Calculates the scale factor for converting world coordinates to minimap coordinates.
- getMinimapPosition(): Gets the position of the minimap on the screen.
*/
public class Minimap
{
private readonly long minimapObjectAddress;
private readonly long minimapHudAddress;
private float scaleFactor;
private JungleCamp[] jungleCamps;
private KindredTracker kindredTracker;
public Minimap(JungleCamp[] jungleCamps, KindredTracker kindredTracker)
{
this.jungleCamps = jungleCamps;
this.kindredTracker = kindredTracker;
minimapObjectAddress = Offsets.Instances.GetMinimapObject;
minimapHudAddress = Memory.Read<long>(minimapObjectAddress + Offsets.Object.MinimapObjectHud);
scaleFactor = getScaleFactor();
}
public void DrawMinimapOverlay()
{
Vector2 vector = getMinimapPosition();
float minimapSize = getMinimapSize();
Presentation.DrawFactory.DrawFilledBox(vector.X, vector.Y, minimapSize, minimapSize, Color.Aqua);
}
public void DrawMarkerOnMinimap()
{
foreach (var camp in jungleCamps)
{
Vector2 vector = WorldToMap(camp.PositionX, camp.PositionY);
Presentation.DrawFactory.DrawPoint(vector.X, vector.Y, Color.Red);
}
}
public void DrawRespawntimerOnMap()
{
String textToDraw;
Vector2 position;
foreach (var camp in jungleCamps)
{
if (camp.IsAlive || camp.RemainingRespawnTime <= TimeSpan.Zero)
{
}
else
{
Color colorCode = camp.Color == Color.Green ? Color.Green : Color.White;
position = WorldToMap(camp.PositionX, camp.PositionY);
textToDraw = $"{camp.RemainingRespawnTime.Minutes}:{camp.RemainingRespawnTime.Seconds:D2}";
Presentation.DrawFactory.DrawFont(textToDraw, FontSize: 20, position, Color.White);
}
}
}
private float getWorldSize()
{
return Memory.Read<float>(minimapHudAddress + Offsets.Object.WorldSize);
}
private float getMinimapSize()
{
return Memory.Read<float>(minimapHudAddress + Offsets.Object.MinimapHudSize);
}
private float getScaleFactor()
{
return getMinimapSize() / getWorldSize();
}
private Vector2 getMinimapPosition()
{
float minimapPosX = Memory.Read<float>(minimapHudAddress + Offsets.Object.MinimapHudPosX);
float minimapPosY = Memory.Read<float>(minimapHudAddress + Offsets.Object.MinimapHudPosY);
return new Vector2(minimapPosX, minimapPosY);
}
public Vector2 WorldToMap(float posX, float posY)
{
Vector2 vector = getMinimapPosition();
float x = (posX * scaleFactor) + vector.X;
float y = vector.Y + getMinimapSize() - (posY * scaleFactor);
return new Vector2(x, y);
}
// This function should be moved out of this class, but we keep it here for simplicity for now
public void DrawKindredMarkRespawnTimer()
{
String textToDraw;
Vector2 position;
position.X = 900;
position.Y = 10;
if (kindredTracker.markTracker.MarkTimerRun)
{
textToDraw =
$"Mark: {kindredTracker.markTracker.MarkRespawnTime.Seconds:D2}";
Presentation.DrawFactory.DrawFont(textToDraw, FontSize: 20, position, Color.White);
}
}
}
/*
class Minimap
{
private float scaleFactor;
private float minimapPosX;
private float minimapPosY;
private float minimapSize;
private float worldSize;
public Minimap()
{
updateScaleFactor();
}
public void updateScaleFactor()
{
long minimapObjectAddress = Offsets.Instances.GetMinimapObject;
long minimapHudAddress = Memory.Read<long>(minimapObjectAddress + Offsets.Object.MinimapObjectHud);
this.worldSize = Memory.Read<float>(minimapHudAddress + Offsets.Object.WorldSize);
this.minimapSize = Memory.Read<float>(minimapHudAddress + Offsets.Object.MinimapHudSize);
this.scaleFactor = minimapSize / this.worldSize;
this.minimapPosX = Memory.Read<float>(minimapHudAddress + Offsets.Object.MinimapHudPosX);
this.minimapPosY = Memory.Read<float>(minimapHudAddress + Offsets.Object.MinimapHudPosY);
}
public Vector2 WorldToMap(float posX, float posY)
{
Vector2 vector;
vector.X = (posX * this.scaleFactor) + this.minimapPosX;
vector.Y = this.minimapPosY + this.minimapSize - (posY * this.scaleFactor);
return vector;
}
public void DrawMinimapOverlay()
{
Presentation.DrawFactory.DrawFilledBox(this.minimapPosX, this.minimapPosY, this.minimapSize, this.minimapSize, Color.Aqua);
}
}
*/
}