Add Map.DistanceAboveTerrain(WPos) and Actor.IsAtGroundLevel() extension method
This commit is contained in:
@@ -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];
|
||||
|
||||
Reference in New Issue
Block a user