Skip to content

Commit

Permalink
Merge pull request LeagueSharp#53 from RoachxD/patch-1
Browse files Browse the repository at this point in the history
IsFacing & IsBothFacing
ehmehe committed Oct 24, 2014
2 parents 6fd5835 + 605fa68 commit dc25bd3
Showing 1 changed file with 35 additions and 8 deletions.
43 changes: 35 additions & 8 deletions LeagueSharp.Common/LeagueSharp.Common/Utility.cs
Original file line number Diff line number Diff line change
@@ -38,6 +38,33 @@ namespace LeagueSharp.Common
/// </summary>
public static class Utility
{
/// <summary>
/// Returns if the source is facing the target.
/// <summary>
public static bool IsFacing(this Obj_AI_Base source, Obj_AI_Base target, float lineLength = 300)
{
if (source == null || target == null)
return false;

return
target.Distance(Vector2.Add(new Vector2(source.Position.X, source.Position.Y),
(Vector2
.Subtract(
new Vector2(source.ServerPosition.X, source.ServerPosition.Y),
new Vector2(source.Position.X, source.Position.Y)).Normalized() * (target.Distance(source))))) <=
lineLength;
}

/// <summary>
/// Returns if both source and target are Facing Themselves.
/// </summary>
public static bool IsBothFacing(Obj_AI_Base source, Obj_AI_Base target, float lineLength)
{
return source.IsFacing(target, lineLength)
&& target.IsFacing
(source, lineLength);
}

/// <summary>
/// Returns if the target is valid (not dead, targetable, visible...).
/// </summary>
@@ -139,14 +166,14 @@ public static bool IsWall(Vector3 position)

public static byte[] GetBytes(string str)
{
var bytes = new byte[str.Length * sizeof (char)];
var bytes = new byte[str.Length * sizeof(char)];
Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}

public static string GetString(byte[] bytes)
{
var chars = new char[bytes.Length / sizeof (char)];
var chars = new char[bytes.Length / sizeof(char)];
Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
return new string(chars);
}
@@ -242,7 +269,7 @@ public static List<Vector2> GetWaypoints(this Obj_AI_Base unit)
var timePassed = (Environment.TickCount - WaypointTracker.StoredTick[unit.NetworkId]) / 1000f;
if (path.PathLength() >= unit.MoveSpeed * timePassed)
{
result = CutPath(path, (int) (unit.MoveSpeed * timePassed));
result = CutPath(path, (int)(unit.MoveSpeed * timePassed));
}
}

@@ -392,7 +419,7 @@ public static void DrawCircle(Vector3 center,
var angle = i * Math.PI * 2 / quality;
pointList.Add(
new Vector3(
center.X + radius * (float) Math.Cos(angle), center.Y + radius * (float) Math.Sin(angle),
center.X + radius * (float)Math.Cos(angle), center.Y + radius * (float)Math.Sin(angle),
center.Z));
}

@@ -515,9 +542,9 @@ var unit in ObjectManager.Get<Obj_AI_Hero>().Where(h => h.IsValid && h.IsHPBarRe

if (damage > unit.Health)
{
Text.X = (int) barPos.X + XOffset;
Text.Y = (int) barPos.Y + YOffset - 13;
Text.text = ((int) (unit.Health - damage)).ToString();
Text.X = (int)barPos.X + XOffset;
Text.Y = (int)barPos.Y + YOffset - 13;
Text.text = ((int)(unit.Health - damage)).ToString();
Text.OnEndScene();
}

@@ -661,4 +688,4 @@ private static void Game_OnGameProcessPacket(GamePacketEventArgs args)
}
}
}
}
}

0 comments on commit dc25bd3

Please sign in to comment.