Remove unnecessary PPos.FromWPosHackZ() usage.
This commit is contained in:
@@ -221,11 +221,15 @@ namespace OpenRA.Graphics
|
|||||||
|
|
||||||
public int2 ScreenPxPosition(WPos pos)
|
public int2 ScreenPxPosition(WPos pos)
|
||||||
{
|
{
|
||||||
var c = Game.CellSize/1024f;
|
return new int2(Game.CellSize*pos.X/1024, Game.CellSize*(pos.Y - pos.Z)/1024);
|
||||||
return new int2((int)(c*pos.X), (int)(c*(pos.Y - pos.Z)));
|
|
||||||
}
|
}
|
||||||
public float ScreenZOffset(WPos pos) { return pos.Z*Game.CellSize/1024f; }
|
public float ScreenZOffset(WPos pos) { return pos.Z*Game.CellSize/1024f; }
|
||||||
|
|
||||||
|
public int2 ScreenPxOffset(WVec vec)
|
||||||
|
{
|
||||||
|
return new int2(Game.CellSize*vec.X/1024, Game.CellSize*(vec.Y - vec.Z)/1024);
|
||||||
|
}
|
||||||
|
|
||||||
public float[] ScreenOffset(WVec vec)
|
public float[] ScreenOffset(WVec vec)
|
||||||
{
|
{
|
||||||
var c = Game.CellSize/1024f;
|
var c = Game.CellSize/1024f;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
anim.Play("turret");
|
anim.Play("turret");
|
||||||
|
|
||||||
anims.Add("turret_{0}".F(i++), new AnimationWithOffset(anim,
|
anims.Add("turret_{0}".F(i++), new AnimationWithOffset(anim,
|
||||||
wr => PPos.FromWPosHackZ(WPos.Zero + t.Position(self)).ToFloat2(), null));
|
wr => wr.ScreenPxOffset(t.Position(self)), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
anim.Play("turret");
|
anim.Play("turret");
|
||||||
|
|
||||||
anims.Add("turret_{0}".F(i++), new AnimationWithOffset(anim,
|
anims.Add("turret_{0}".F(i++), new AnimationWithOffset(anim,
|
||||||
wr => TurretPosition(self, turret, facing), null));
|
wr => TurretPosition(self, wr, turret, facing), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float2 TurretPosition(Actor self, Turreted t, IFacing facing)
|
float2 TurretPosition(Actor self, WorldRenderer wr, Turreted t, IFacing facing)
|
||||||
{
|
{
|
||||||
var recoil = self.TraitsImplementing<Armament>()
|
var recoil = self.TraitsImplementing<Armament>()
|
||||||
.Where(w => w.Info.Turret == t.Name)
|
.Where(w => w.Info.Turret == t.Name)
|
||||||
@@ -50,9 +50,9 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero);
|
var localOffset = new WVec(-recoil, WRange.Zero, WRange.Zero);
|
||||||
var bodyOrientation = QuantizeOrientation(self, self.Orientation);
|
var bodyOrientation = QuantizeOrientation(self, self.Orientation);
|
||||||
var turretOrientation = QuantizeOrientation(self, t.LocalOrientation(self));
|
var turretOrientation = QuantizeOrientation(self, t.LocalOrientation(self));
|
||||||
var worldPos = WPos.Zero + t.Position(self) + LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));
|
var worldPos = t.Position(self) + LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));
|
||||||
|
|
||||||
return PPos.FromWPosHackZ(worldPos).ToFloat2();
|
return wr.ScreenPxOffset(worldPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
muzzleFlashes.Add("muzzle{0}".F(muzzleFlashes.Count), new AnimationWithOffset(
|
muzzleFlashes.Add("muzzle{0}".F(muzzleFlashes.Count), new AnimationWithOffset(
|
||||||
muzzleFlash,
|
muzzleFlash,
|
||||||
wr => PPos.FromWPosHackZ(WPos.Zero + a.MuzzleOffset(self, barrel)).ToFloat2(),
|
wr => wr.ScreenPxOffset(a.MuzzleOffset(self, barrel)),
|
||||||
() => !isShowing));
|
() => !isShowing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user