Remove CVec -> WVec conversion.
This commit is contained in:
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
{
|
||||
var width = bi.Dimensions.X;
|
||||
var bibOffset = bi.Dimensions.Y - 1;
|
||||
var centerOffset = FootprintUtils.CenterOffset(bi);
|
||||
var centerOffset = FootprintUtils.CenterOffset(self.World, bi);
|
||||
var location = self.Location;
|
||||
var rows = info.HasMinibib ? 1 : 2;
|
||||
var map = self.World.Map;
|
||||
@@ -49,16 +49,17 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
var index = i;
|
||||
var anim = new Animation(self.World, rs.GetImage(self));
|
||||
var cellOffset = new CVec(i % width, i / width + bibOffset);
|
||||
var cell = location + cellOffset;
|
||||
|
||||
// Some mods may define terrain-specific bibs
|
||||
var terrain = map.GetTerrainInfo(location + cellOffset).Type;
|
||||
var terrain = map.GetTerrainInfo(cell).Type;
|
||||
var testSequence = info.Sequence + "-" + terrain;
|
||||
var sequence = anim.HasSequence(testSequence) ? testSequence : info.Sequence;
|
||||
anim.PlayFetchIndex(sequence, () => index);
|
||||
anim.IsDecoration = true;
|
||||
|
||||
// Z-order is one set to the top of the footprint
|
||||
var offset = cellOffset.ToWVec() - centerOffset;
|
||||
var offset = self.World.Map.CenterOfCell(cell) - self.World.Map.CenterOfCell(location) - centerOffset;
|
||||
var awo = new AnimationWithOffset(anim, () => offset, null, -(offset.Y + centerOffset.Y + 512));
|
||||
rs.Add("bib_{0}".F(i), awo, info.Palette);
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
|
||||
public Actor FindBaseProvider(World world, Player p, CPos topLeft)
|
||||
{
|
||||
var center = world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(this);
|
||||
var center = world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(world, this);
|
||||
foreach (var bp in world.ActorsWithTrait<BaseProvider>())
|
||||
{
|
||||
var validOwner = bp.Actor.Owner == p || (world.LobbyInfo.GlobalSettings.AllyBuildRadius && bp.Actor.Owner.Stances[p] == Stance.Ally);
|
||||
@@ -137,7 +137,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
occupiedCells = FootprintUtils.UnpathableTiles( self.Info.Name, Info, TopLeft )
|
||||
.Select(c => Pair.New(c, SubCell.FullCell)).ToArray();
|
||||
|
||||
CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(Info);
|
||||
CenterPosition = init.world.Map.CenterOfCell(topLeft) + FootprintUtils.CenterOffset(init.world, Info);
|
||||
BuildComplete = init.Contains<SkipMakeAnimsInit>();
|
||||
}
|
||||
|
||||
|
||||
@@ -62,11 +62,10 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
return new CVec(dim.X / 2, dim.Y > 1 ? (dim.Y + 1) / 2 : 0);
|
||||
}
|
||||
|
||||
public static WVec CenterOffset(BuildingInfo buildingInfo)
|
||||
public static WVec CenterOffset(World w, BuildingInfo buildingInfo)
|
||||
{
|
||||
var dim = buildingInfo.Dimensions;
|
||||
// Offset is measured relative to the center of the cell, so need to subtract an additional half cell.
|
||||
return new CVec(dim.X, dim.Y).ToWVec() / 2 - new WVec(512, 512, 0);
|
||||
return (w.Map.CenterOfCell(CPos.Zero + new CVec(dim.X, dim.Y)) - w.Map.CenterOfCell(new CPos(1, 1))) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user