-
Notifications
You must be signed in to change notification settings - Fork 11
/
SafeMovement.cs
68 lines (62 loc) · 1.97 KB
/
SafeMovement.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 System;
using System.IO;
using LeagueSharp;
using LeagueSharp.Common;
namespace SAwareness
{
internal class SafeMovement
{
private decimal _lastSend;
public SafeMovement()
{
Game.OnGameSendPacket += Game_OnGameSendPacket;
}
~SafeMovement()
{
Game.OnGameSendPacket -= Game_OnGameSendPacket;
}
public bool IsActive()
{
return Menu.Misc.GetActive() && Menu.SafeMovement.GetActive();
}
private void Game_OnGameSendPacket(GamePacketEventArgs args)
{
if (!IsActive())
return;
try
{
decimal milli = DateTime.Now.Ticks/(decimal) TimeSpan.TicksPerMillisecond;
var reader = new BinaryReader(new MemoryStream(args.PacketData));
byte packetId = reader.ReadByte();
if (packetId != Packet.C2S.Move.Header)
return;
Packet.C2S.Move.Struct move = Packet.C2S.Move.Decoded(args.PacketData);
if (move.MoveType == 2)
{
if (move.SourceNetworkId == ObjectManager.Player.NetworkId)
{
if (milli - _lastSend <
Menu.SafeMovement.GetMenuItem("SAwarenessSafeMovementBlockIntervall")
.GetValue<Slider>()
.Value)
{
args.Process = false;
}
else
{
_lastSend = milli;
}
}
}
else if (move.MoveType == 3)
{
_lastSend = 0;
}
}
catch (Exception ex)
{
Console.WriteLine("MovementProcess: " + ex);
}
}
}
}