-
Автор темы
- #1
Помогите что куда вставлять под LW и есть ли тут ошибки
Код:
// in main loop
if (Config.EspGrenadeTrajectories)
DrawGrenadeTrajectories();
Код:
// in ESP class
private readonly Dictionary<int, IList<Vector3>> _grenadeTrails = new Dictionary<int, IList<Vector3>>();
Код:
private void DrawGrenadeTrajectories()
{
// find all grenades to draw trajectories for. Extend if you like. Convert ToList to prevent redundant enumeration.
var grenades = Orion.Objects.Entities.Where(e => e.ClassId == (int) CsgoClassId.CSMOKEGRENADEPROJECTILE).ToList();
// remove old trails from the cache. No need to draw them anymore. ToList again to prevent crashes on modified enumerators.
foreach (var kvp in _grenadeTrails.ToList().Where(kvp => grenades.All(g => g.Id != kvp.Key)))
_grenadeTrails.Remove(kvp.Key);
// add them new positions to the cache. Might want to check for update frequency, as the cache might get quite large.
foreach (var grenade in grenades)
{
if (_grenadeTrails.ContainsKey(grenade.Id))
{
_grenadeTrails[grenade.Id].Add(grenade.Position);
}
else
{
_grenadeTrails[grenade.Id] = new List<Vector3> {grenade.Position};
}
}
// just draw the grenade trails where we have at least 2 cached positions. SharpDX will crash otherwise.
var trailsToDraw = _grenadeTrails.Values.Where(trail => trail.Count > 1);
var viewMatrix = Orion.Memory.Read<Matrix4x4>(Orion.ClientBase + Offsets.ViewMatrix);
_line.Width = 1;
foreach (var trail in trailsToDraw)
{
// get the path to be drawn on screen. Usual W2S
var sPath = trail.Select(pos => _windowRect.TopLeft + WorldToScreen(viewMatrix, _windowRect.Size, pos)).ToArray();
_line.Draw(sPath, Color.Lime);
}
}