Remove legacy turret/muzzle positioning code.
This commit is contained in:
@@ -18,16 +18,8 @@ using OpenRA.Traits;
|
|||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
public enum CoordinateModel { Legacy, World };
|
|
||||||
|
|
||||||
public class Barrel
|
public class Barrel
|
||||||
{
|
{
|
||||||
// Legacy coordinates
|
|
||||||
public PVecInt TurretSpaceOffset; // position in turret space
|
|
||||||
public PVecInt ScreenSpaceOffset; // screen-space hack to make things line up good.
|
|
||||||
public int Facing; // deviation from turret facing
|
|
||||||
|
|
||||||
// World coordinates
|
|
||||||
public WVec Offset;
|
public WVec Offset;
|
||||||
public WAngle Yaw;
|
public WAngle Yaw;
|
||||||
}
|
}
|
||||||
@@ -44,10 +36,6 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Time (in frames) until the weapon can fire again.")]
|
[Desc("Time (in frames) until the weapon can fire again.")]
|
||||||
public readonly int FireDelay = 0;
|
public readonly int FireDelay = 0;
|
||||||
|
|
||||||
public readonly float LegacyRecoilRecovery = 0.2f;
|
|
||||||
public readonly int[] LegacyLocalOffset = { };
|
|
||||||
|
|
||||||
public CoordinateModel OffsetModel = CoordinateModel.Legacy;
|
|
||||||
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
||||||
public readonly WRange[] LocalOffset = {};
|
public readonly WRange[] LocalOffset = {};
|
||||||
[Desc("Muzzle yaw relative to turret or body.")]
|
[Desc("Muzzle yaw relative to turret or body.")]
|
||||||
@@ -57,14 +45,7 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Recoil recovery per-frame")]
|
[Desc("Recoil recovery per-frame")]
|
||||||
public readonly WRange RecoilRecovery = new WRange(9);
|
public readonly WRange RecoilRecovery = new WRange(9);
|
||||||
|
|
||||||
public object Create(ActorInitializer init)
|
public object Create(ActorInitializer init) { return new Armament(init.self, this); }
|
||||||
{
|
|
||||||
// Auto-detect coordinate type
|
|
||||||
if (LocalOffset.Length > 0 && OffsetModel == CoordinateModel.Legacy)
|
|
||||||
OffsetModel = CoordinateModel.World;
|
|
||||||
|
|
||||||
return new Armament(init.self, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Armament : ITick
|
public class Armament : ITick
|
||||||
@@ -76,7 +57,6 @@ namespace OpenRA.Mods.RA
|
|||||||
Lazy<ILocalCoordinatesModel> Coords;
|
Lazy<ILocalCoordinatesModel> Coords;
|
||||||
|
|
||||||
public WRange Recoil;
|
public WRange Recoil;
|
||||||
public float LegacyRecoil { get; private set; }
|
|
||||||
public int FireDelay { get; private set; }
|
public int FireDelay { get; private set; }
|
||||||
public int Burst { get; private set; }
|
public int Burst { get; private set; }
|
||||||
|
|
||||||
@@ -91,38 +71,22 @@ namespace OpenRA.Mods.RA
|
|||||||
Weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
Weapon = Rules.Weapons[info.Weapon.ToLowerInvariant()];
|
||||||
Burst = Weapon.Burst;
|
Burst = Weapon.Burst;
|
||||||
|
|
||||||
|
if (info.LocalOffset.Length % 3 != 0)
|
||||||
|
throw new InvalidOperationException("Invalid LocalOffset array length");
|
||||||
|
|
||||||
var barrels = new List<Barrel>();
|
var barrels = new List<Barrel>();
|
||||||
|
for (var i = 0; i < info.LocalOffset.Length / 3; i++)
|
||||||
if (Info.OffsetModel == CoordinateModel.Legacy)
|
|
||||||
{
|
{
|
||||||
for (var i = 0; i < info.LocalOffset.Length / 5; i++)
|
barrels.Add(new Barrel
|
||||||
barrels.Add(new Barrel
|
|
||||||
{
|
|
||||||
TurretSpaceOffset = new PVecInt(info.LegacyLocalOffset[5 * i], info.LegacyLocalOffset[5 * i + 1]),
|
|
||||||
ScreenSpaceOffset = new PVecInt(info.LegacyLocalOffset[5 * i + 2], info.LegacyLocalOffset[5 * i + 3]),
|
|
||||||
Facing = info.LegacyLocalOffset[5 * i + 4],
|
|
||||||
});
|
|
||||||
|
|
||||||
// if no barrels specified, the default is "turret position; turret facing".
|
|
||||||
if (barrels.Count == 0)
|
|
||||||
barrels.Add(new Barrel { TurretSpaceOffset = PVecInt.Zero, ScreenSpaceOffset = PVecInt.Zero, Facing = 0 });
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (info.LocalOffset.Length % 3 != 0)
|
|
||||||
throw new InvalidOperationException("Invalid LocalOffset array length");
|
|
||||||
|
|
||||||
for (var i = 0; i < info.LocalOffset.Length / 3; i++)
|
|
||||||
{
|
{
|
||||||
barrels.Add(new Barrel
|
Offset = new WVec(info.LocalOffset[3*i], info.LocalOffset[3*i + 1], info.LocalOffset[3*i + 2]),
|
||||||
{
|
Yaw = info.LocalYaw.Length > i ? info.LocalYaw[i] : WAngle.Zero
|
||||||
Offset = new WVec(info.LocalOffset[3*i], info.LocalOffset[3*i + 1], info.LocalOffset[3*i + 2]),
|
});
|
||||||
Yaw = info.LocalYaw.Length > i ? info.LocalYaw[i] : WAngle.Zero
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (barrels.Count == 0)
|
|
||||||
barrels.Add(new Barrel { Offset = WVec.Zero, Yaw = WAngle.Zero });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (barrels.Count == 0)
|
||||||
|
barrels.Add(new Barrel { Offset = WVec.Zero, Yaw = WAngle.Zero });
|
||||||
|
|
||||||
Barrels = barrels.ToArray();
|
Barrels = barrels.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +94,6 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
if (FireDelay > 0)
|
if (FireDelay > 0)
|
||||||
--FireDelay;
|
--FireDelay;
|
||||||
LegacyRecoil = Math.Max(0f, LegacyRecoil - Info.LegacyRecoilRecovery);
|
|
||||||
Recoil = new WRange(Math.Max(0, Recoil.Range - Info.RecoilRecovery.Range));
|
Recoil = new WRange(Math.Max(0, Recoil.Range - Info.RecoilRecovery.Range));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -151,19 +114,10 @@ namespace OpenRA.Mods.RA
|
|||||||
var barrel = Barrels[Burst % Barrels.Length];
|
var barrel = Barrels[Burst % Barrels.Length];
|
||||||
var destMove = target.IsActor ? target.Actor.TraitOrDefault<IMove>() : null;
|
var destMove = target.IsActor ? target.Actor.TraitOrDefault<IMove>() : null;
|
||||||
|
|
||||||
var legacyMuzzlePosition = self.CenterLocation + (PVecInt)MuzzlePxOffset(self, facing, barrel).ToInt2();
|
var muzzlePosition = self.CenterPosition + MuzzleOffset(self, barrel);
|
||||||
var legacyMuzzleAltitude = move != null ? move.Altitude : 0;
|
var legacyMuzzlePosition = PPos.FromWPos(muzzlePosition);
|
||||||
var legacyFacing = barrel.Facing + (Turret.Value != null ? Turret.Value.turretFacing :
|
var legacyMuzzleAltitude = Game.CellSize*muzzlePosition.Z/1024;
|
||||||
facing != null ? facing.Facing : Util.GetFacing(target.CenterLocation - self.CenterLocation, 0));
|
var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4;
|
||||||
|
|
||||||
if (Info.OffsetModel == CoordinateModel.World)
|
|
||||||
{
|
|
||||||
var muzzlePosition = self.CenterPosition + MuzzleOffset(self, barrel);
|
|
||||||
legacyMuzzlePosition = PPos.FromWPos(muzzlePosition);
|
|
||||||
legacyMuzzleAltitude = Game.CellSize*muzzlePosition.Z/1024;
|
|
||||||
|
|
||||||
legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
var args = new ProjectileArgs
|
var args = new ProjectileArgs
|
||||||
{
|
{
|
||||||
@@ -199,7 +153,6 @@ namespace OpenRA.Mods.RA
|
|||||||
foreach (var na in self.TraitsImplementing<INotifyAttack>())
|
foreach (var na in self.TraitsImplementing<INotifyAttack>())
|
||||||
na.Attacking(self, target);
|
na.Attacking(self, target);
|
||||||
|
|
||||||
LegacyRecoil = Info.LegacyRecoil;
|
|
||||||
Recoil = Info.Recoil;
|
Recoil = Info.Recoil;
|
||||||
|
|
||||||
if (--Burst > 0)
|
if (--Burst > 0)
|
||||||
@@ -221,48 +174,8 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public bool IsReloading { get { return FireDelay > 0; } }
|
public bool IsReloading { get { return FireDelay > 0; } }
|
||||||
|
|
||||||
PVecFloat GetUnitspaceBarrelOffset(Actor self, IFacing facing, Barrel b)
|
|
||||||
{
|
|
||||||
if (Turret.Value == null && facing == null)
|
|
||||||
return PVecFloat.Zero;
|
|
||||||
|
|
||||||
var turretFacing = Turret.Value != null ? Turret.Value.turretFacing : facing.Facing;
|
|
||||||
return (PVecFloat)Util.RotateVectorByFacing(b.TurretSpaceOffset.ToFloat2(), turretFacing, .7f);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Note: facing is only used by the legacy positioning code
|
|
||||||
public PVecFloat MuzzlePxOffset(Actor self, IFacing facing, Barrel b)
|
|
||||||
{
|
|
||||||
// Hack for external code unaware of world coordinates
|
|
||||||
if (Info.OffsetModel == CoordinateModel.World)
|
|
||||||
return (PVecFloat)PPos.FromWPosHackZ(WPos.Zero + MuzzleOffset(self, b)).ToFloat2();
|
|
||||||
|
|
||||||
PVecFloat pos = b.ScreenSpaceOffset;
|
|
||||||
|
|
||||||
// local facing offset doesn't make sense for actors that don't rotate
|
|
||||||
if (Turret.Value == null && facing == null)
|
|
||||||
return pos;
|
|
||||||
|
|
||||||
if (Turret.Value != null)
|
|
||||||
pos += Turret.Value.PxPosition(self, facing);
|
|
||||||
|
|
||||||
// Add local unitspace/turretspace offset
|
|
||||||
var f = Turret.Value != null ? Turret.Value.turretFacing : facing.Facing;
|
|
||||||
|
|
||||||
// This is going away, so no point adding unnecessary usings
|
|
||||||
var ru = self.TraitOrDefault<RenderUnit>();
|
|
||||||
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
|
|
||||||
var quantizedFacing = Util.QuantizeFacing(f, numDirs) * (256 / numDirs);
|
|
||||||
|
|
||||||
pos += (PVecFloat)Util.RotateVectorByFacing(b.TurretSpaceOffset.ToFloat2(), quantizedFacing, .7f);
|
|
||||||
return pos;
|
|
||||||
}
|
|
||||||
|
|
||||||
public WVec MuzzleOffset(Actor self, Barrel b)
|
public WVec MuzzleOffset(Actor self, Barrel b)
|
||||||
{
|
{
|
||||||
if (Info.OffsetModel != CoordinateModel.World)
|
|
||||||
throw new InvalidOperationException("Armament.MuzzlePosition requires a world coordinate offset");
|
|
||||||
|
|
||||||
var bodyOrientation = Coords.Value.QuantizeOrientation(self, self.Orientation);
|
var bodyOrientation = Coords.Value.QuantizeOrientation(self, self.Orientation);
|
||||||
var localOffset = b.Offset + new WVec(-Recoil, WRange.Zero, WRange.Zero);
|
var localOffset = b.Offset + new WVec(-Recoil, WRange.Zero, WRange.Zero);
|
||||||
if (Turret.Value != null)
|
if (Turret.Value != null)
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public DebugFiringOffsets(Actor self)
|
public DebugFiringOffsets(Actor self)
|
||||||
{
|
{
|
||||||
armaments = Lazy.New(() => self.TraitsImplementing<Armament>()
|
armaments = Lazy.New(() => self.TraitsImplementing<Armament>());
|
||||||
.Where(a => a.Info.OffsetModel == CoordinateModel.World));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
public void RenderAfterWorld(WorldRenderer wr, Actor self)
|
||||||
|
|||||||
@@ -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,
|
||||||
() => t.PxPosition(self, null).ToFloat2(), null));
|
() => PPos.FromWPosHackZ(WPos.Zero + t.Position(self)).ToFloat2(), null));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,26 +43,16 @@ namespace OpenRA.Mods.RA.Render
|
|||||||
|
|
||||||
float2 TurretPosition(Actor self, Turreted t, IFacing facing)
|
float2 TurretPosition(Actor self, Turreted t, IFacing facing)
|
||||||
{
|
{
|
||||||
if (t.CoordinateModel == CoordinateModel.Legacy)
|
var recoil = self.TraitsImplementing<Armament>()
|
||||||
{
|
.Where(w => w.Info.Turret == t.Name)
|
||||||
var recoil = self.TraitsImplementing<Armament>()
|
.Aggregate(WRange.Zero, (a,b) => a + b.Recoil);
|
||||||
.Where(w => w.Info.Turret == t.Name)
|
|
||||||
.Sum(w => w.LegacyRecoil);
|
|
||||||
return t.PxPosition(self, facing).ToFloat2() + Traits.Util.RotateVectorByFacing(new float2(0, recoil), t.turretFacing, .7f);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var recoil = self.TraitsImplementing<Armament>()
|
|
||||||
.Where(w => w.Info.Turret == t.Name)
|
|
||||||
.Aggregate(WRange.Zero, (a,b) => a + b.Recoil);
|
|
||||||
|
|
||||||
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 = WPos.Zero + t.Position(self) + LocalToWorld(localOffset.Rotate(turretOrientation).Rotate(bodyOrientation));
|
||||||
|
|
||||||
return PPos.FromWPosHackZ(worldPos).ToFloat2();
|
return PPos.FromWPosHackZ(worldPos).ToFloat2();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,
|
||||||
() => a.MuzzlePxOffset(self, facing, barrel).ToFloat2(),
|
() => PPos.FromWPosHackZ(WPos.Zero + a.MuzzleOffset(self, barrel)).ToFloat2(),
|
||||||
() => !isShowing));
|
() => !isShowing));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ namespace OpenRA.Mods.RA
|
|||||||
public readonly int ProneTime = 100; /* ticks, =4s */
|
public readonly int ProneTime = 100; /* ticks, =4s */
|
||||||
public readonly float ProneDamage = .5f;
|
public readonly float ProneDamage = .5f;
|
||||||
public readonly decimal ProneSpeed = .5m;
|
public readonly decimal ProneSpeed = .5m;
|
||||||
public readonly int[] LegacyProneOffset = {0,-2,0,4};
|
|
||||||
public readonly WVec ProneOffset = new WVec(85, 0, -171);
|
public readonly WVec ProneOffset = new WVec(85, 0, -171);
|
||||||
|
|
||||||
public override object Create(ActorInitializer init) { return new TakeCover(init, this); }
|
public override object Create(ActorInitializer init) { return new TakeCover(init, this); }
|
||||||
@@ -44,10 +43,8 @@ namespace OpenRA.Mods.RA
|
|||||||
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne)) /* Don't go prone when healed */
|
if (e.Damage > 0 && (e.Warhead == null || !e.Warhead.PreventProne)) /* Don't go prone when healed */
|
||||||
{
|
{
|
||||||
if (!IsProne)
|
if (!IsProne)
|
||||||
{
|
|
||||||
turret = new Turret(Info.LegacyProneOffset);
|
|
||||||
LocalOffset = Info.ProneOffset;
|
LocalOffset = Info.ProneOffset;
|
||||||
}
|
|
||||||
remainingProneTime = Info.ProneTime;
|
remainingProneTime = Info.ProneTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,10 +53,7 @@ namespace OpenRA.Mods.RA
|
|||||||
{
|
{
|
||||||
base.Tick(self);
|
base.Tick(self);
|
||||||
if (IsProne && --remainingProneTime == 0)
|
if (IsProne && --remainingProneTime == 0)
|
||||||
{
|
|
||||||
turret = new Turret(Info.LegacyOffset);
|
|
||||||
LocalOffset = WVec.Zero;
|
LocalOffset = WVec.Zero;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetDamageModifier(Actor attacker, WarheadInfo warhead )
|
public float GetDamageModifier(Actor attacker, WarheadInfo warhead )
|
||||||
|
|||||||
@@ -23,28 +23,12 @@ namespace OpenRA.Mods.RA
|
|||||||
[Desc("Rate of Turning")]
|
[Desc("Rate of Turning")]
|
||||||
public readonly int ROT = 255;
|
public readonly int ROT = 255;
|
||||||
public readonly int InitialFacing = 128;
|
public readonly int InitialFacing = 128;
|
||||||
public readonly int[] LegacyOffset = {0,0};
|
|
||||||
public readonly bool AlignWhenIdle = false;
|
public readonly bool AlignWhenIdle = false;
|
||||||
|
|
||||||
public CoordinateModel OffsetModel = CoordinateModel.Legacy;
|
|
||||||
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
[Desc("Muzzle position relative to turret or body. (forward, right, up) triples")]
|
||||||
public readonly WVec Offset = WVec.Zero;
|
public readonly WVec Offset = WVec.Zero;
|
||||||
|
|
||||||
|
public virtual object Create(ActorInitializer init) { return new Turreted(init, this); }
|
||||||
bool HasWorldOffset(ArmamentInfo ai)
|
|
||||||
{
|
|
||||||
return ai.OffsetModel == CoordinateModel.World || ai.LocalOffset.Length > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual object Create(ActorInitializer init)
|
|
||||||
{
|
|
||||||
// Auto-detect coordinate type
|
|
||||||
var arms = init.self.Info.Traits.WithInterface<ArmamentInfo>();
|
|
||||||
if (Offset != WVec.Zero || arms.Any(ai => HasWorldOffset(ai)))
|
|
||||||
OffsetModel = CoordinateModel.World;
|
|
||||||
|
|
||||||
return new Turreted(init, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Turreted : ITick, ISync, IResolveOrder
|
public class Turreted : ITick, ISync, IResolveOrder
|
||||||
@@ -52,7 +36,6 @@ namespace OpenRA.Mods.RA
|
|||||||
[Sync] public int turretFacing = 0;
|
[Sync] public int turretFacing = 0;
|
||||||
public int? desiredFacing;
|
public int? desiredFacing;
|
||||||
TurretedInfo info;
|
TurretedInfo info;
|
||||||
protected Turret turret;
|
|
||||||
IFacing facing;
|
IFacing facing;
|
||||||
|
|
||||||
// For subclasses that want to move the turret relative to the body
|
// For subclasses that want to move the turret relative to the body
|
||||||
@@ -60,7 +43,6 @@ namespace OpenRA.Mods.RA
|
|||||||
|
|
||||||
public WVec Offset { get { return info.Offset + LocalOffset; } }
|
public WVec Offset { get { return info.Offset + LocalOffset; } }
|
||||||
public string Name { get { return info.Turret; } }
|
public string Name { get { return info.Turret; } }
|
||||||
public CoordinateModel CoordinateModel { get { return info.OffsetModel; } }
|
|
||||||
|
|
||||||
public static int GetInitialTurretFacing(ActorInitializer init, int def)
|
public static int GetInitialTurretFacing(ActorInitializer init, int def)
|
||||||
{
|
{
|
||||||
@@ -78,7 +60,6 @@ namespace OpenRA.Mods.RA
|
|||||||
this.info = info;
|
this.info = info;
|
||||||
turretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
turretFacing = GetInitialTurretFacing(init, info.InitialFacing);
|
||||||
facing = init.self.TraitOrDefault<IFacing>();
|
facing = init.self.TraitOrDefault<IFacing>();
|
||||||
turret = new Turret(info.LegacyOffset);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void Tick(Actor self)
|
public virtual void Tick(Actor self)
|
||||||
@@ -99,21 +80,9 @@ namespace OpenRA.Mods.RA
|
|||||||
desiredFacing = null;
|
desiredFacing = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PVecFloat PxPosition(Actor self, IFacing facing)
|
|
||||||
{
|
|
||||||
// Hack for external code unaware of world coordinates
|
|
||||||
if (info.OffsetModel == CoordinateModel.World)
|
|
||||||
return (PVecFloat)PPos.FromWPosHackZ(WPos.Zero + Position(self)).ToFloat2();
|
|
||||||
|
|
||||||
return turret.PxPosition(self, facing);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Turret offset in world-space
|
// Turret offset in world-space
|
||||||
public WVec Position(Actor self)
|
public WVec Position(Actor self)
|
||||||
{
|
{
|
||||||
if (info.OffsetModel != CoordinateModel.World)
|
|
||||||
throw new InvalidOperationException("Turreted.Position requires a world coordinate offset");
|
|
||||||
|
|
||||||
var coords = self.Trait<ILocalCoordinatesModel>();
|
var coords = self.Trait<ILocalCoordinatesModel>();
|
||||||
var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
|
var bodyOrientation = coords.QuantizeOrientation(self, self.Orientation);
|
||||||
return coords.LocalToWorld(Offset.Rotate(bodyOrientation));
|
return coords.LocalToWorld(Offset.Rotate(bodyOrientation));
|
||||||
@@ -127,6 +96,7 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Remove this
|
||||||
public class Turret
|
public class Turret
|
||||||
{
|
{
|
||||||
public PVecInt UnitSpacePosition; // where, in the unit's local space.
|
public PVecInt UnitSpacePosition; // where, in the unit's local space.
|
||||||
|
|||||||
@@ -102,7 +102,6 @@ JEEP:
|
|||||||
Offset: -85,0,171
|
Offset: -85,0,171
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: MachineGun
|
Weapon: MachineGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
@@ -135,7 +134,6 @@ APC:
|
|||||||
ROT: 10
|
ROT: 10
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: MachineGun
|
Weapon: MachineGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
@@ -174,7 +172,6 @@ BGGY:
|
|||||||
Offset: -43,0,128
|
Offset: -43,0,128
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: MachineGun
|
Weapon: MachineGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
|
|||||||
@@ -216,7 +216,6 @@ BGGY:
|
|||||||
Offset: -43,0,128
|
Offset: -43,0,128
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: MachineGun
|
Weapon: MachineGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
@@ -292,7 +291,6 @@ JEEP:
|
|||||||
Offset: -85,0,171
|
Offset: -85,0,171
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: MachineGun
|
Weapon: MachineGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ MSUB:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: SubMissile
|
Weapon: SubMissile
|
||||||
FireDelay: 2
|
FireDelay: 2
|
||||||
OffsetModel: World
|
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 44,44
|
Bounds: 44,44
|
||||||
@@ -245,10 +244,8 @@ PT:
|
|||||||
Offset: 256,0,43
|
Offset: 256,0,43
|
||||||
Armament@PRIMARY:
|
Armament@PRIMARY:
|
||||||
Weapon: 2Inch
|
Weapon: 2Inch
|
||||||
OffsetModel: World
|
|
||||||
Armament@SECONDARY:
|
Armament@SECONDARY:
|
||||||
Weapon: DepthCharge
|
Weapon: DepthCharge
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 32,32
|
Bounds: 32,32
|
||||||
|
|||||||
@@ -496,7 +496,6 @@ GUN:
|
|||||||
RenderBuildingTurreted:
|
RenderBuildingTurreted:
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: TurretGun
|
Weapon: TurretGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
@@ -568,7 +567,6 @@ SAM:
|
|||||||
RenderBuildingTurreted:
|
RenderBuildingTurreted:
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Nike
|
Weapon: Nike
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ V2RL:
|
|||||||
Range: 5
|
Range: 5
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: SCUD
|
Weapon: SCUD
|
||||||
OffsetModel: World
|
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
RenderUnitReload:
|
RenderUnitReload:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -54,7 +53,6 @@ V2RL:
|
|||||||
Weapon: 25mm
|
Weapon: 25mm
|
||||||
Recoil: 85
|
Recoil: 85
|
||||||
RecoilRecovery: 25
|
RecoilRecovery: 25
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -88,7 +86,6 @@ V2RL:
|
|||||||
Weapon: 90mm
|
Weapon: 90mm
|
||||||
Recoil: 128
|
Recoil: 128
|
||||||
RecoilRecovery: 38
|
RecoilRecovery: 38
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -203,7 +200,6 @@ ARTY:
|
|||||||
Range: 5
|
Range: 5
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: 155mm
|
Weapon: 155mm
|
||||||
OffsetModel: World
|
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
Explodes:
|
Explodes:
|
||||||
@@ -314,7 +310,6 @@ JEEP:
|
|||||||
Offset: 0,0,85
|
Offset: 0,0,85
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: M60mg
|
Weapon: M60mg
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
|
|||||||
@@ -84,7 +84,6 @@ MSUB:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: SubMissile
|
Weapon: SubMissile
|
||||||
FireDelay: 2
|
FireDelay: 2
|
||||||
OffsetModel: World
|
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 44,44
|
Bounds: 44,44
|
||||||
@@ -259,10 +258,8 @@ PT:
|
|||||||
Offset: 256,0,43
|
Offset: 256,0,43
|
||||||
Armament@PRIMARY:
|
Armament@PRIMARY:
|
||||||
Weapon: 2Inch
|
Weapon: 2Inch
|
||||||
OffsetModel: World
|
|
||||||
Armament@SECONDARY:
|
Armament@SECONDARY:
|
||||||
Weapon: DepthCharge
|
Weapon: DepthCharge
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
Selectable:
|
Selectable:
|
||||||
Bounds: 32,32
|
Bounds: 32,32
|
||||||
|
|||||||
@@ -328,10 +328,8 @@ AGUN:
|
|||||||
RenderBuildingTurreted:
|
RenderBuildingTurreted:
|
||||||
Armament@PRIMARY:
|
Armament@PRIMARY:
|
||||||
Weapon: ZSU-23
|
Weapon: ZSU-23
|
||||||
OffsetModel: World
|
|
||||||
Armament@SECONDARY:
|
Armament@SECONDARY:
|
||||||
Weapon: ZSU-23
|
Weapon: ZSU-23
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
@@ -748,7 +746,6 @@ GUN:
|
|||||||
RenderBuildingTurreted:
|
RenderBuildingTurreted:
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: TurretGun
|
Weapon: TurretGun
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
DebugRetiliateAgainstAggressor:
|
DebugRetiliateAgainstAggressor:
|
||||||
@@ -828,7 +825,6 @@ SAM:
|
|||||||
RenderBuildingTurreted:
|
RenderBuildingTurreted:
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: Nike
|
Weapon: Nike
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ V2RL:
|
|||||||
Range: 5
|
Range: 5
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: SCUD
|
Weapon: SCUD
|
||||||
OffsetModel: World
|
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
RenderUnitReload:
|
RenderUnitReload:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -57,7 +56,6 @@ V2RL:
|
|||||||
Weapon: 25mm
|
Weapon: 25mm
|
||||||
Recoil: 85
|
Recoil: 85
|
||||||
RecoilRecovery: 25
|
RecoilRecovery: 25
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -97,7 +95,6 @@ V2RL:
|
|||||||
Weapon: 90mm
|
Weapon: 90mm
|
||||||
Recoil: 128
|
Recoil: 128
|
||||||
RecoilRecovery: 38
|
RecoilRecovery: 38
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
@@ -229,7 +226,6 @@ ARTY:
|
|||||||
Range: 5
|
Range: 5
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: 155mm
|
Weapon: 155mm
|
||||||
OffsetModel: World
|
|
||||||
AttackFrontal:
|
AttackFrontal:
|
||||||
RenderUnit:
|
RenderUnit:
|
||||||
Explodes:
|
Explodes:
|
||||||
@@ -346,7 +342,6 @@ JEEP:
|
|||||||
Offset: 0,0,85
|
Offset: 0,0,85
|
||||||
Armament:
|
Armament:
|
||||||
Weapon: M60mg
|
Weapon: M60mg
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
WithMuzzleFlash:
|
WithMuzzleFlash:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
@@ -683,7 +678,6 @@ FTRK:
|
|||||||
Armament:
|
Armament:
|
||||||
Weapon: FLAK-23
|
Weapon: FLAK-23
|
||||||
Recoil: 85
|
Recoil: 85
|
||||||
OffsetModel: World
|
|
||||||
AttackTurreted:
|
AttackTurreted:
|
||||||
RenderUnitTurreted:
|
RenderUnitTurreted:
|
||||||
AutoTarget:
|
AutoTarget:
|
||||||
|
|||||||
Reference in New Issue
Block a user