Fix airlift direction in isometric mods.
This commit is contained in:
@@ -51,24 +51,26 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
|
|
||||||
var info = (ProductionAirdropInfo)Info;
|
var info = (ProductionAirdropInfo)Info;
|
||||||
var owner = self.Owner;
|
var owner = self.Owner;
|
||||||
|
var map = owner.World.Map;
|
||||||
var aircraftInfo = self.World.Map.Rules.Actors[info.ActorType].TraitInfo<AircraftInfo>();
|
var aircraftInfo = self.World.Map.Rules.Actors[info.ActorType].TraitInfo<AircraftInfo>();
|
||||||
var mpStart = owner.World.WorldActor.TraitOrDefault<MPStartLocations>();
|
var mpStart = owner.World.WorldActor.TraitOrDefault<MPStartLocations>();
|
||||||
|
|
||||||
if (info.BaselineSpawn && mpStart != null)
|
if (info.BaselineSpawn && mpStart != null)
|
||||||
{
|
{
|
||||||
var spawn = mpStart.Start[owner];
|
var spawn = mpStart.Start[owner];
|
||||||
var bounds = owner.World.Map.Bounds;
|
var bounds = map.Bounds;
|
||||||
var center = new CPos(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2);
|
var center = new MPos(bounds.Left + bounds.Width / 2, bounds.Top + bounds.Height / 2).ToCPos(map);
|
||||||
var spawnVec = spawn - center;
|
var spawnVec = spawn - center;
|
||||||
startPos = spawn + spawnVec * (Math.Max(bounds.Height, bounds.Width) / (2 * spawnVec.Length));
|
startPos = spawn + spawnVec * (Exts.ISqrt((bounds.Height * bounds.Height + bounds.Width * bounds.Width) / (4 * spawnVec.LengthSquared)));
|
||||||
endPos = startPos;
|
endPos = startPos;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Start a fixed distance away: the width of the map.
|
// Start a fixed distance away: the width of the map.
|
||||||
// This makes the production timing independent of spawnpoint
|
// This makes the production timing independent of spawnpoint
|
||||||
startPos = self.Location + new CVec(owner.World.Map.Bounds.Width, 0);
|
var loc = self.Location.ToMPos(map);
|
||||||
endPos = new CPos(owner.World.Map.Bounds.Left, self.Location.Y);
|
startPos = new MPos(loc.U + map.Bounds.Width, loc.V).ToCPos(map);
|
||||||
|
endPos = new MPos(map.Bounds.Left, loc.V).ToCPos(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assume a single exit point for simplicity
|
// Assume a single exit point for simplicity
|
||||||
|
|||||||
Reference in New Issue
Block a user