ProjectileArgs facing -> WAngle.

This commit is contained in:
Paul Chote
2020-05-08 20:54:29 +01:00
committed by reaperrr
parent 6d6b21a0eb
commit 2cfacc2c7d
8 changed files with 17 additions and 21 deletions

View File

@@ -24,8 +24,8 @@ namespace OpenRA.GameRules
public int[] DamageModifiers; public int[] DamageModifiers;
public int[] InaccuracyModifiers; public int[] InaccuracyModifiers;
public int[] RangeModifiers; public int[] RangeModifiers;
public int Facing; public WAngle Facing;
public Func<int> CurrentMuzzleFacing; public Func<WAngle> CurrentMuzzleFacing;
public WPos Source; public WPos Source;
public Func<WPos> CurrentSource; public Func<WPos> CurrentSource;
public Actor SourceActor; public Actor SourceActor;

View File

@@ -65,14 +65,13 @@ namespace OpenRA.Mods.Common.Projectiles
this.info = info; this.info = info;
this.args = args; this.args = args;
pos = args.Source; pos = args.Source;
var facing = WAngle.FromFacing(args.Facing);
var convertedVelocity = new WVec(info.Velocity.Y, -info.Velocity.X, info.Velocity.Z); var convertedVelocity = new WVec(info.Velocity.Y, -info.Velocity.X, info.Velocity.Z);
velocity = convertedVelocity.Rotate(WRot.FromYaw(facing)); velocity = convertedVelocity.Rotate(WRot.FromYaw(args.Facing));
acceleration = new WVec(info.Acceleration.Y, -info.Acceleration.X, info.Acceleration.Z); acceleration = new WVec(info.Acceleration.Y, -info.Acceleration.X, info.Acceleration.Z);
if (!string.IsNullOrEmpty(info.Image)) if (!string.IsNullOrEmpty(info.Image))
{ {
anim = new Animation(args.SourceActor.World, info.Image, () => facing); anim = new Animation(args.SourceActor.World, info.Image, () => args.Facing);
if (!string.IsNullOrEmpty(info.OpenSequence)) if (!string.IsNullOrEmpty(info.OpenSequence))
anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom))); anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom)));

View File

@@ -149,11 +149,8 @@ namespace OpenRA.Mods.Common.Projectiles
source = args.CurrentSource(); source = args.CurrentSource();
if (hasLaunchEffect && ticks == 0) if (hasLaunchEffect && ticks == 0)
{ world.AddFrameEndTask(w => w.Add(new SpriteEffect(args.CurrentSource, args.CurrentMuzzleFacing, world,
Func<WAngle> getMuzzleFacing = () => WAngle.FromFacing(args.CurrentMuzzleFacing());
world.AddFrameEndTask(w => w.Add(new SpriteEffect(args.CurrentSource, getMuzzleFacing, world,
info.LaunchEffectImage, info.LaunchEffectSequence, info.LaunchEffectPalette))); info.LaunchEffectImage, info.LaunchEffectSequence, info.LaunchEffectPalette)));
}
// Beam tracks target // Beam tracks target
if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor)) if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor))

View File

@@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Projectiles
this.args = args; this.args = args;
pos = args.Source; pos = args.Source;
hFacing = args.Facing; hFacing = args.Facing.Facing;
gravity = new WVec(0, 0, -info.Gravity); gravity = new WVec(0, 0, -info.Gravity);
targetPosition = args.PassiveTarget; targetPosition = args.PassiveTarget;
rangeLimit = info.RangeLimit != WDist.Zero ? info.RangeLimit : args.Weapon.Range; rangeLimit = info.RangeLimit != WDist.Zero ? info.RangeLimit : args.Weapon.Range;

View File

@@ -281,8 +281,8 @@ namespace OpenRA.Mods.Common.Traits
na.PreparingAttack(self, target, this, barrel); na.PreparingAttack(self, target, this, barrel);
Func<WPos> muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel); Func<WPos> muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel);
var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4; Func<WAngle> muzzleFacing = () => MuzzleOrientation(self, barrel).Yaw;
Func<int> legacyMuzzleFacing = () => MuzzleOrientation(self, barrel).Yaw.Angle / 4; var muzzleOrientation = WRot.FromYaw(muzzleFacing());
var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition()); var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition());
var initialOffset = Weapon.FirstBurstTargetOffset; var initialOffset = Weapon.FirstBurstTargetOffset;
@@ -290,7 +290,7 @@ namespace OpenRA.Mods.Common.Traits
{ {
// We want this to match Armament.LocalOffset, so we need to convert it to forward, right, up // We want this to match Armament.LocalOffset, so we need to convert it to forward, right, up
initialOffset = new WVec(initialOffset.Y, -initialOffset.X, initialOffset.Z); initialOffset = new WVec(initialOffset.Y, -initialOffset.X, initialOffset.Z);
passiveTarget += initialOffset.Rotate(WRot.FromFacing(legacyFacing)); passiveTarget += initialOffset.Rotate(muzzleOrientation);
} }
var followingOffset = Weapon.FollowingBurstTargetOffset; var followingOffset = Weapon.FollowingBurstTargetOffset;
@@ -298,14 +298,14 @@ namespace OpenRA.Mods.Common.Traits
{ {
// We want this to match Armament.LocalOffset, so we need to convert it to forward, right, up // We want this to match Armament.LocalOffset, so we need to convert it to forward, right, up
followingOffset = new WVec(followingOffset.Y, -followingOffset.X, followingOffset.Z); followingOffset = new WVec(followingOffset.Y, -followingOffset.X, followingOffset.Z);
passiveTarget += ((Weapon.Burst - Burst) * followingOffset).Rotate(WRot.FromFacing(legacyFacing)); passiveTarget += ((Weapon.Burst - Burst) * followingOffset).Rotate(muzzleOrientation);
} }
var args = new ProjectileArgs var args = new ProjectileArgs
{ {
Weapon = Weapon, Weapon = Weapon,
Facing = legacyFacing, Facing = muzzleFacing(),
CurrentMuzzleFacing = legacyMuzzleFacing, CurrentMuzzleFacing = muzzleFacing,
DamageModifiers = damageModifiers.ToArray(), DamageModifiers = damageModifiers.ToArray(),

View File

@@ -68,8 +68,8 @@ namespace OpenRA.Mods.Common.Traits
var args = new ProjectileArgs var args = new ProjectileArgs
{ {
Weapon = wep, Weapon = wep,
Facing = self.World.SharedRandom.Next(-1, 255), Facing = new WAngle(self.World.SharedRandom.Next(1024)),
CurrentMuzzleFacing = () => 0, CurrentMuzzleFacing = () => WAngle.Zero,
DamageModifiers = self.TraitsImplementing<IFirepowerModifier>() DamageModifiers = self.TraitsImplementing<IFirepowerModifier>()
.Select(a => a.GetFirepowerModifier()).ToArray(), .Select(a => a.GetFirepowerModifier()).ToArray(),

View File

@@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Warheads
var projectileArgs = new ProjectileArgs var projectileArgs = new ProjectileArgs
{ {
Weapon = weapon, Weapon = weapon,
Facing = (map.CenterOfCell(targetCell) - target.CenterPosition).Yaw.Facing, Facing = (map.CenterOfCell(targetCell) - target.CenterPosition).Yaw,
DamageModifiers = args.DamageModifiers, DamageModifiers = args.DamageModifiers,
InaccuracyModifiers = new int[0], InaccuracyModifiers = new int[0],

View File

@@ -133,8 +133,8 @@ namespace OpenRA.Mods.D2k.Traits
var args = new ProjectileArgs var args = new ProjectileArgs
{ {
Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()], Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()],
Facing = 0, Facing = WAngle.Zero,
CurrentMuzzleFacing = () => 0, CurrentMuzzleFacing = () => WAngle.Zero,
DamageModifiers = self.TraitsImplementing<IFirepowerModifier>() DamageModifiers = self.TraitsImplementing<IFirepowerModifier>()
.Select(a => a.GetFirepowerModifier()).ToArray(), .Select(a => a.GetFirepowerModifier()).ToArray(),