Add WPos.ToCPos().
This commit is contained in:
@@ -21,8 +21,6 @@ namespace OpenRA
|
|||||||
public readonly int X, Y;
|
public readonly int X, Y;
|
||||||
|
|
||||||
public CPos(int x, int y) { X = x; Y = y; }
|
public CPos(int x, int y) { X = x; Y = y; }
|
||||||
public CPos(WPos a) { X = a.X / 1024; Y = a.Y / 1024; }
|
|
||||||
|
|
||||||
public static readonly CPos Zero = new CPos(0, 0);
|
public static readonly CPos Zero = new CPos(0, 0);
|
||||||
|
|
||||||
public static explicit operator CPos(int2 a) { return new CPos(a.X, a.Y); }
|
public static explicit operator CPos(int2 a) { return new CPos(a.X, a.Y); }
|
||||||
@@ -71,4 +69,9 @@ namespace OpenRA
|
|||||||
public static CPos TopLeftAsCPos(this Rectangle r) { return new CPos(r.Left, r.Top); }
|
public static CPos TopLeftAsCPos(this Rectangle r) { return new CPos(r.Left, r.Top); }
|
||||||
public static CPos BottomRightAsCPos(this Rectangle r) { return new CPos(r.Right, r.Bottom); }
|
public static CPos BottomRightAsCPos(this Rectangle r) { return new CPos(r.Right, r.Bottom); }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public static class WPosExtensions
|
||||||
|
{
|
||||||
|
public static CPos ToCPos(this WPos a) { return new CPos(a.X / 1024, a.Y / 1024); }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -60,13 +60,13 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
// Start of the first line segment is the tail of the list - don't smooth it.
|
// Start of the first line segment is the tail of the list - don't smooth it.
|
||||||
var curPos = trail[idx(next - skip - 1)];
|
var curPos = trail[idx(next - skip - 1)];
|
||||||
var curCell = new CPos(curPos);
|
var curCell = curPos.ToCPos();
|
||||||
var curColor = color;
|
var curColor = color;
|
||||||
for (var i = 0; i < length - skip - 4; i++)
|
for (var i = 0; i < length - skip - 4; i++)
|
||||||
{
|
{
|
||||||
var j = next - skip - i - 2;
|
var j = next - skip - i - 2;
|
||||||
var nextPos = WPos.Average(trail[idx(j)], trail[idx(j-1)], trail[idx(j-2)], trail[idx(j-3)]);
|
var nextPos = WPos.Average(trail[idx(j)], trail[idx(j-1)], trail[idx(j-2)], trail[idx(j-3)]);
|
||||||
var nextCell = new CPos(nextPos);
|
var nextCell = nextPos.ToCPos();
|
||||||
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
|
var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent);
|
||||||
|
|
||||||
if (!world.FogObscures(curCell) && !world.FogObscures(nextCell))
|
if (!world.FogObscures(curCell) && !world.FogObscures(nextCell))
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ namespace OpenRA.Mods.RA.Effects
|
|||||||
parachuteOffset = pai.Offset;
|
parachuteOffset = pai.Offset;
|
||||||
|
|
||||||
// Adjust x,y to match the target subcell
|
// Adjust x,y to match the target subcell
|
||||||
cargo.Trait<ITeleportable>().SetPosition(cargo, new CPos(dropPosition));
|
cargo.Trait<ITeleportable>().SetPosition(cargo, dropPosition.ToCPos());
|
||||||
var cp = cargo.CenterPosition;
|
var cp = cargo.CenterPosition;
|
||||||
pos = new WPos(cp.X, cp.Y, dropPosition.Z);
|
pos = new WPos(cp.X, cp.Y, dropPosition.Z);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var position = self.CenterPosition;
|
var position = self.CenterPosition;
|
||||||
if (position.Z > 0 && self.GetDamageState() >= info.MinDamage &&
|
if (position.Z > 0 && self.GetDamageState() >= info.MinDamage &&
|
||||||
!self.World.FogObscures(new CPos(position)))
|
!self.World.FogObscures(position.ToCPos()))
|
||||||
{
|
{
|
||||||
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
|
var offset = info.Offset.Rotate(body.QuantizeOrientation(self, self.Orientation));
|
||||||
var pos = position + body.LocalToWorld(offset);
|
var pos = position + body.LocalToWorld(offset);
|
||||||
|
|||||||
Reference in New Issue
Block a user