Disallow units idling on service depot.

This commit is contained in:
tovl
2019-09-22 23:52:11 +02:00
committed by Paul Chote
parent c360d8bcef
commit 434c46058f
10 changed files with 86 additions and 18 deletions

View File

@@ -23,7 +23,8 @@ namespace OpenRA.Mods.Common.Traits
Empty = '_',
OccupiedPassable = '=',
Occupied = 'x',
OccupiedUntargetable = 'X'
OccupiedUntargetable = 'X',
OccupiedPassableTransitOnly = '+'
}
public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, IPlaceBuildingDecorationInfo
@@ -107,6 +108,9 @@ namespace OpenRA.Mods.Common.Traits
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedUntargetable))
yield return t;
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedPassableTransitOnly))
yield return t;
}
public IEnumerable<CPos> FrozenUnderFogTiles(CPos location)
@@ -118,13 +122,16 @@ namespace OpenRA.Mods.Common.Traits
yield return t;
}
public IEnumerable<CPos> UnpathableTiles(CPos location)
public IEnumerable<CPos> OccupiedTiles(CPos location)
{
foreach (var t in FootprintTiles(location, FootprintCellType.Occupied))
yield return t;
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedUntargetable))
yield return t;
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedPassableTransitOnly))
yield return t;
}
public IEnumerable<CPos> PathableTiles(CPos location)
@@ -136,6 +143,12 @@ namespace OpenRA.Mods.Common.Traits
yield return t;
}
public IEnumerable<CPos> TransitOnlyTiles(CPos location)
{
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedPassableTransitOnly))
yield return t;
}
public WVec CenterOffset(World w)
{
var off = (w.Map.CenterOfCell(new CPos(Dimensions.X, Dimensions.Y)) - w.Map.CenterOfCell(new CPos(1, 1))) / 2;
@@ -225,7 +238,7 @@ namespace OpenRA.Mods.Common.Traits
public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos topLeft, SubCell subCell = SubCell.Any)
{
var occupied = UnpathableTiles(topLeft)
var occupied = OccupiedTiles(topLeft)
.ToDictionary(c => c, c => SubCell.FullCell);
return new ReadOnlyDictionary<CPos, SubCell>(occupied);
@@ -255,6 +268,7 @@ namespace OpenRA.Mods.Common.Traits
Pair<CPos, SubCell>[] occupiedCells;
Pair<CPos, SubCell>[] targetableCells;
CPos[] transitOnlyCells;
public CPos TopLeft { get { return topLeft; } }
public WPos CenterPosition { get; private set; }
@@ -266,17 +280,21 @@ namespace OpenRA.Mods.Common.Traits
Info = info;
influence = self.World.WorldActor.Trait<BuildingInfluence>();
occupiedCells = Info.UnpathableTiles(TopLeft)
occupiedCells = Info.OccupiedTiles(TopLeft)
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Occupied)
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
transitOnlyCells = Info.TransitOnlyTiles(TopLeft).ToArray();
CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World);
}
public Pair<CPos, SubCell>[] OccupiedCells() { return occupiedCells; }
public CPos[] TransitOnlyCells() { return transitOnlyCells; }
Pair<CPos, SubCell>[] ITargetableCells.TargetableCells() { return targetableCells; }
void INotifyAddedToWorld.AddedToWorld(Actor self)