Fix GiveUnitCrateAction being limited to MobileInfo

This commit is contained in:
abcdefg30
2017-02-09 13:11:01 +01:00
parent ac9c8b93a2
commit a385835939
5 changed files with 54 additions and 21 deletions

View File

@@ -38,6 +38,30 @@ namespace OpenRA.Mods.Common.Traits
}
bool IOccupySpaceInfo.SharesCell { get { return false; } }
public bool CanEnterCell(World world, Actor self, CPos cell, Actor ignoreActor = null, bool checkTransientActors = true)
{
return GetAvailableSubCell(world, cell, ignoreActor, checkTransientActors) != SubCell.Invalid;
}
public SubCell GetAvailableSubCell(World world, CPos cell, Actor ignoreActor = null, bool checkTransientActors = true)
{
if (!world.Map.Contains(cell))
return SubCell.Invalid;
var type = world.Map.GetTerrainInfo(cell).Type;
if (!TerrainTypes.Contains(type))
return SubCell.Invalid;
if (world.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
return SubCell.Invalid;
if (!checkTransientActors)
return SubCell.FullCell;
return !world.ActorMap.GetActorsAt(cell).Any(x => x != ignoreActor)
? SubCell.FullCell : SubCell.Invalid;
}
}
class Crate : ITick, IPositionable, ICrushable, ISync,
@@ -174,22 +198,7 @@ namespace OpenRA.Mods.Common.Traits
public SubCell GetValidSubCell(SubCell preferred = SubCell.Any) { return SubCell.FullCell; }
public SubCell GetAvailableSubCell(CPos cell, SubCell preferredSubCell = SubCell.Any, Actor ignoreActor = null, bool checkTransientActors = true)
{
if (!self.World.Map.Contains(cell))
return SubCell.Invalid;
var type = self.World.Map.GetTerrainInfo(cell).Type;
if (!info.TerrainTypes.Contains(type))
return SubCell.Invalid;
if (self.World.WorldActor.Trait<BuildingInfluence>().GetBuildingAt(cell) != null)
return SubCell.Invalid;
if (!checkTransientActors)
return SubCell.FullCell;
return !self.World.ActorMap.GetActorsAt(cell)
.Any(x => x != ignoreActor)
? SubCell.FullCell : SubCell.Invalid;
return info.GetAvailableSubCell(self.World, cell, ignoreActor, checkTransientActors);
}
public bool CanEnterCell(CPos a, Actor ignoreActor = null, bool checkTransientActors = true)