Add OccupiedUntargetable FootprintCellType

For cells that are occupied & unpassable, but should be ignored by HitShape.UseOccupiedCellsOffsets.
This commit is contained in:
reaperrr
2017-07-05 01:22:05 +02:00
committed by abcdefg30
parent fdb3866238
commit 5bdb7bd689

View File

@@ -27,7 +27,8 @@ namespace OpenRA.Mods.Common.Traits
{ {
Empty = '_', Empty = '_',
OccupiedPassable = '=', OccupiedPassable = '=',
Blocking = 'x' Occupied = 'x',
OccupiedUntargetable = 'X'
} }
public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, IPlaceBuildingDecorationInfo, UsesInit<LocationInit> public class BuildingInfo : ITraitInfo, IOccupySpaceInfo, IPlaceBuildingDecorationInfo, UsesInit<LocationInit>
@@ -38,8 +39,8 @@ namespace OpenRA.Mods.Common.Traits
[Desc("The range to the next building it can be constructed. Set it higher for walls.")] [Desc("The range to the next building it can be constructed. Set it higher for walls.")]
public readonly int Adjacent = 2; public readonly int Adjacent = 2;
[Desc("x means cell is blocked, = means part of the footprint but passable, ", [Desc("x means cell is blocked, capital X means blocked but not counting as targetable, ",
"_ means completely empty.")] "= means part of the footprint but passable, _ means completely empty.")]
[FieldLoader.LoadUsing("LoadFootprint")] [FieldLoader.LoadUsing("LoadFootprint")]
public readonly Dictionary<CVec, FootprintCellType> Footprint; public readonly Dictionary<CVec, FootprintCellType> Footprint;
@@ -109,7 +110,10 @@ namespace OpenRA.Mods.Common.Traits
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedPassable)) foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedPassable))
yield return t; yield return t;
foreach (var t in FootprintTiles(location, FootprintCellType.Blocking)) foreach (var t in FootprintTiles(location, FootprintCellType.Occupied))
yield return t;
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedUntargetable))
yield return t; yield return t;
} }
@@ -124,7 +128,10 @@ namespace OpenRA.Mods.Common.Traits
public IEnumerable<CPos> UnpathableTiles(CPos location) public IEnumerable<CPos> UnpathableTiles(CPos location)
{ {
foreach (var t in FootprintTiles(location, FootprintCellType.Blocking)) foreach (var t in FootprintTiles(location, FootprintCellType.Occupied))
yield return t;
foreach (var t in FootprintTiles(location, FootprintCellType.OccupiedUntargetable))
yield return t; yield return t;
} }
@@ -271,7 +278,7 @@ namespace OpenRA.Mods.Common.Traits
occupiedCells = Info.UnpathableTiles(TopLeft) occupiedCells = Info.UnpathableTiles(TopLeft)
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Blocking) targetableCells = Info.FootprintTiles(TopLeft, FootprintCellType.Occupied)
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray(); .Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World); CenterPosition = init.World.Map.CenterOfCell(topLeft) + Info.CenterOffset(init.World);