Add IPositionable.CanExistInCell

This is like CanEnterCell, but doesn't take into account conflicting
actors, etc.
This commit is contained in:
Chris Forbes
2018-04-06 20:37:56 -07:00
committed by abcdefg30
parent fba08cd066
commit dddd057e3d
6 changed files with 32 additions and 6 deletions

View File

@@ -44,13 +44,21 @@ namespace OpenRA.Mods.Common.Traits
return GetAvailableSubCell(world, cell, ignoreActor, checkTransientActors) != SubCell.Invalid;
}
public SubCell GetAvailableSubCell(World world, CPos cell, Actor ignoreActor = null, bool checkTransientActors = true)
public bool CanExistInCell(World world, CPos cell)
{
if (!world.Map.Contains(cell))
return SubCell.Invalid;
return false;
var type = world.Map.GetTerrainInfo(cell).Type;
if (!TerrainTypes.Contains(type))
return false;
return true;
}
public SubCell GetAvailableSubCell(World world, CPos cell, Actor ignoreActor = null, bool checkTransientActors = true)
{
if (!CanExistInCell(world, cell))
return SubCell.Invalid;
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
@@ -201,6 +209,8 @@ namespace OpenRA.Mods.Common.Traits
return info.GetAvailableSubCell(self.World, cell, ignoreActor, checkTransientActors);
}
public bool CanExistInCell(CPos cell) { return info.CanExistInCell(self.World, cell); }
public bool CanEnterCell(CPos a, Actor ignoreActor = null, bool checkTransientActors = true)
{
return GetAvailableSubCell(a, SubCell.Any, ignoreActor, checkTransientActors) != SubCell.Invalid;