Add Map.DistanceAboveTerrain(WPos) and Actor.IsAtGroundLevel() extension method

This commit is contained in:
Taryn Hill
2015-08-01 07:53:14 -05:00
parent 7066254887
commit 6fa1f757b0
8 changed files with 36 additions and 13 deletions

View File

@@ -18,6 +18,25 @@ namespace OpenRA.Mods.Common
{
public static class ActorExts
{
public static bool IsAtGroundLevel(this Actor self)
{
if (self.IsDead)
return false;
if (!self.HasTrait<IPositionable>())
return false;
if (!self.IsInWorld)
return false;
var map = self.World.Map;
if (!map.Contains(self.Location))
return false;
return map.DistanceAboveTerrain(self.CenterPosition).Length == 0;
}
public static bool AppearsFriendlyTo(this Actor self, Actor toActor)
{
var stance = toActor.Owner.Stances[self.Owner];