use PVecFloat in Combat sub-routines
This commit is contained in:
@@ -208,18 +208,18 @@ namespace OpenRA.Mods.RA
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static float2 GetRecoil(Actor self, float recoil)
|
static PVecFloat GetRecoil(Actor self, float recoil)
|
||||||
{
|
{
|
||||||
if (!self.HasTrait<RenderUnitTurreted>())
|
if (!self.HasTrait<RenderUnitTurreted>())
|
||||||
return float2.Zero;
|
return PVecFloat.Zero;
|
||||||
|
|
||||||
var facing = self.Trait<Turreted>().turretFacing;
|
var facing = self.Trait<Turreted>().turretFacing;
|
||||||
var localRecoil = new float2(0, recoil); // vector in turret-space.
|
var localRecoil = new float2(0, recoil); // vector in turret-space.
|
||||||
|
|
||||||
return Util.RotateVectorByFacing(localRecoil, facing, .7f);
|
return (PVecFloat)Util.RotateVectorByFacing(localRecoil, facing, .7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PVecInt GetTurretPosition(Actor self, IFacing facing, Turret turret)
|
public static PVecFloat GetTurretPosition(Actor self, IFacing facing, Turret turret)
|
||||||
{
|
{
|
||||||
if (facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
|
if (facing == null) return turret.ScreenSpacePosition; /* things that don't have a rotating base don't need the turrets repositioned */
|
||||||
|
|
||||||
@@ -228,23 +228,23 @@ namespace OpenRA.Mods.RA
|
|||||||
var bodyFacing = facing.Facing;
|
var bodyFacing = facing.Facing;
|
||||||
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
|
||||||
|
|
||||||
return (PVecInt) ((PVecFloat)(Util.RotateVectorByFacing(turret.UnitSpacePosition.ToFloat2(), quantizedFacing, .7f)
|
return (PVecFloat)Util.RotateVectorByFacing(turret.UnitSpacePosition.ToFloat2(), quantizedFacing, .7f)
|
||||||
+ GetRecoil(self, turret.Recoil))
|
+ GetRecoil(self, turret.Recoil)
|
||||||
+ turret.ScreenSpacePosition);
|
+ (PVecFloat)turret.ScreenSpacePosition.ToFloat2();
|
||||||
}
|
}
|
||||||
|
|
||||||
static PVecInt GetUnitspaceBarrelOffset(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
static PVecFloat GetUnitspaceBarrelOffset(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
||||||
{
|
{
|
||||||
var turreted = self.TraitOrDefault<Turreted>();
|
var turreted = self.TraitOrDefault<Turreted>();
|
||||||
if (turreted == null && facing == null)
|
if (turreted == null && facing == null)
|
||||||
return PVecInt.Zero;
|
return PVecFloat.Zero;
|
||||||
|
|
||||||
var turretFacing = turreted != null ? turreted.turretFacing : facing.Facing;
|
var turretFacing = turreted != null ? turreted.turretFacing : facing.Facing;
|
||||||
return (PVecInt)(PVecFloat)Util.RotateVectorByFacing(barrel.TurretSpaceOffset.ToFloat2(), turretFacing, .7f);
|
return (PVecFloat)Util.RotateVectorByFacing(barrel.TurretSpaceOffset.ToFloat2(), turretFacing, .7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
// gets the screen-space position of a barrel.
|
// gets the screen-space position of a barrel.
|
||||||
public static PVecInt GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
public static PVecFloat GetBarrelPosition(Actor self, IFacing facing, Turret turret, Barrel barrel)
|
||||||
{
|
{
|
||||||
return GetTurretPosition(self, facing, turret) + barrel.ScreenSpaceOffset
|
return GetTurretPosition(self, facing, turret) + barrel.ScreenSpaceOffset
|
||||||
+ GetUnitspaceBarrelOffset(self, facing, turret, barrel);
|
+ GetUnitspaceBarrelOffset(self, facing, turret, barrel);
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public void Tick(Actor self)
|
public void Tick(Actor self)
|
||||||
{
|
{
|
||||||
history.Tick(self.CenterLocation - new PVecInt(0, move.Altitude) - Combat.GetTurretPosition(self, facing, contrailTurret));
|
history.Tick(self.CenterLocation - new PVecInt(0, move.Altitude) - (PVecInt)Combat.GetTurretPosition(self, facing, contrailTurret).ToInt2());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); }
|
public void RenderAfterWorld(WorldRenderer wr, Actor self) { history.Render(self); }
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
var facing = self.Trait<IFacing>();
|
var facing = self.Trait<IFacing>();
|
||||||
var altitude = new PVecInt(0, move.Altitude);
|
var altitude = new PVecInt(0, move.Altitude);
|
||||||
position = (self.CenterLocation - Combat.GetTurretPosition(self, facing, smokeTurret));
|
position = (self.CenterLocation - (PVecInt)Combat.GetTurretPosition(self, facing, smokeTurret).ToInt2());
|
||||||
|
|
||||||
if (self.World.RenderedShroud.IsVisible(position.ToCPos()))
|
if (self.World.RenderedShroud.IsVisible(position.ToCPos()))
|
||||||
self.World.AddFrameEndTask(
|
self.World.AddFrameEndTask(
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ namespace OpenRA.Mods.RA
|
|||||||
firedBy = self,
|
firedBy = self,
|
||||||
target = target,
|
target = target,
|
||||||
|
|
||||||
src = (self.CenterLocation + Combat.GetBarrelPosition(self, facing, Turret, barrel)),
|
src = (self.CenterLocation + (PVecInt)Combat.GetBarrelPosition(self, facing, Turret, barrel).ToInt2()),
|
||||||
srcAltitude = move != null ? move.Altitude : 0,
|
srcAltitude = move != null ? move.Altitude : 0,
|
||||||
dest = target.CenterLocation,
|
dest = target.CenterLocation,
|
||||||
destAltitude = destMove != null ? destMove.Altitude : 0,
|
destAltitude = destMove != null ? destMove.Altitude : 0,
|
||||||
|
|||||||
Reference in New Issue
Block a user