Add Map.DistanceAboveTerrain(WPos) and Actor.IsAtGroundLevel() extension method
This commit is contained in:
@@ -171,7 +171,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public bool CanLoad(Actor self, Actor a)
|
||||
{
|
||||
return (reserves.Contains(a) || HasSpace(GetWeight(a))) && self.CenterPosition.Z == 0;
|
||||
return (reserves.Contains(a) || HasSpace(GetWeight(a))) && self.IsAtGroundLevel();
|
||||
}
|
||||
|
||||
internal bool ReserveSpace(Actor a)
|
||||
|
||||
@@ -189,11 +189,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public bool CrushableBy(string[] crushClasses, Player owner)
|
||||
{
|
||||
// Crate can only be crushed if it is not in the air or underground
|
||||
if (CenterPosition.Z != 0)
|
||||
return false;
|
||||
|
||||
return crushClasses.Contains(info.CrushClass);
|
||||
// Crate can only be crushed if it is not in the air.
|
||||
return self.IsAtGroundLevel() && crushClasses.Contains(info.CrushClass);
|
||||
}
|
||||
|
||||
public void AddedToWorld(Actor self)
|
||||
|
||||
@@ -65,8 +65,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public bool CrushableBy(string[] crushClasses, Player crushOwner)
|
||||
{
|
||||
// Only make actor crushable if it is on the ground
|
||||
if (self.CenterPosition.Z != 0)
|
||||
// Only make actor crushable if it is on the ground.
|
||||
if (!self.IsAtGroundLevel())
|
||||
return false;
|
||||
|
||||
if (!info.CrushedByFriendlies && crushOwner.IsAlliedWith(self.Owner))
|
||||
|
||||
@@ -65,7 +65,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return;
|
||||
|
||||
var cp = self.CenterPosition;
|
||||
if ((cp.Z > 0 && !info.EjectInAir) || (cp.Z == 0 && !info.EjectOnGround))
|
||||
var inAir = !self.IsAtGroundLevel();
|
||||
if ((inAir && !info.EjectInAir) || (!inAir && !info.EjectOnGround))
|
||||
return;
|
||||
|
||||
var pilot = self.World.CreateActor(false, info.PilotActor.ToLowerInvariant(),
|
||||
@@ -73,7 +74,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
if (info.AllowUnsuitableCell || IsSuitableCell(self, pilot))
|
||||
{
|
||||
if (cp.Z > 0)
|
||||
if (inAir)
|
||||
{
|
||||
self.World.AddFrameEndTask(w =>
|
||||
{
|
||||
|
||||
@@ -565,7 +565,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public void FinishedMoving(Actor self)
|
||||
{
|
||||
// Only make actor crush if it is on the ground
|
||||
if (self.CenterPosition.Z != 0)
|
||||
if (!self.IsAtGroundLevel())
|
||||
return;
|
||||
|
||||
var crushables = self.World.ActorMap.GetUnitsAt(ToCell).Where(a => a != self)
|
||||
|
||||
Reference in New Issue
Block a user