diff --git a/OpenRA.Game/GameRules/WeaponInfo.cs b/OpenRA.Game/GameRules/WeaponInfo.cs index abbebd1b50..f1afbb77c6 100644 --- a/OpenRA.Game/GameRules/WeaponInfo.cs +++ b/OpenRA.Game/GameRules/WeaponInfo.cs @@ -24,8 +24,8 @@ namespace OpenRA.GameRules public int[] DamageModifiers; public int[] InaccuracyModifiers; public int[] RangeModifiers; - public int Facing; - public Func CurrentMuzzleFacing; + public WAngle Facing; + public Func CurrentMuzzleFacing; public WPos Source; public Func CurrentSource; public Actor SourceActor; diff --git a/OpenRA.Mods.Common/Projectiles/GravityBomb.cs b/OpenRA.Mods.Common/Projectiles/GravityBomb.cs index 18bfa40665..9deb1b905f 100644 --- a/OpenRA.Mods.Common/Projectiles/GravityBomb.cs +++ b/OpenRA.Mods.Common/Projectiles/GravityBomb.cs @@ -65,14 +65,13 @@ namespace OpenRA.Mods.Common.Projectiles this.info = info; this.args = args; pos = args.Source; - var facing = WAngle.FromFacing(args.Facing); 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); 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)) anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom))); diff --git a/OpenRA.Mods.Common/Projectiles/LaserZap.cs b/OpenRA.Mods.Common/Projectiles/LaserZap.cs index 3696a6efdd..2855e6ec62 100644 --- a/OpenRA.Mods.Common/Projectiles/LaserZap.cs +++ b/OpenRA.Mods.Common/Projectiles/LaserZap.cs @@ -149,11 +149,8 @@ namespace OpenRA.Mods.Common.Projectiles source = args.CurrentSource(); if (hasLaunchEffect && ticks == 0) - { - Func getMuzzleFacing = () => WAngle.FromFacing(args.CurrentMuzzleFacing()); - world.AddFrameEndTask(w => w.Add(new SpriteEffect(args.CurrentSource, getMuzzleFacing, world, + world.AddFrameEndTask(w => w.Add(new SpriteEffect(args.CurrentSource, args.CurrentMuzzleFacing, world, info.LaunchEffectImage, info.LaunchEffectSequence, info.LaunchEffectPalette))); - } // Beam tracks target if (info.TrackTarget && args.GuidedTarget.IsValidFor(args.SourceActor)) diff --git a/OpenRA.Mods.Common/Projectiles/Missile.cs b/OpenRA.Mods.Common/Projectiles/Missile.cs index b88d16e77b..10d120da02 100644 --- a/OpenRA.Mods.Common/Projectiles/Missile.cs +++ b/OpenRA.Mods.Common/Projectiles/Missile.cs @@ -218,7 +218,7 @@ namespace OpenRA.Mods.Common.Projectiles this.args = args; pos = args.Source; - hFacing = args.Facing; + hFacing = args.Facing.Facing; gravity = new WVec(0, 0, -info.Gravity); targetPosition = args.PassiveTarget; rangeLimit = info.RangeLimit != WDist.Zero ? info.RangeLimit : args.Weapon.Range; diff --git a/OpenRA.Mods.Common/Traits/Armament.cs b/OpenRA.Mods.Common/Traits/Armament.cs index 08b7c0a428..98ab3575a7 100644 --- a/OpenRA.Mods.Common/Traits/Armament.cs +++ b/OpenRA.Mods.Common/Traits/Armament.cs @@ -281,8 +281,8 @@ namespace OpenRA.Mods.Common.Traits na.PreparingAttack(self, target, this, barrel); Func muzzlePosition = () => self.CenterPosition + MuzzleOffset(self, barrel); - var legacyFacing = MuzzleOrientation(self, barrel).Yaw.Angle / 4; - Func legacyMuzzleFacing = () => MuzzleOrientation(self, barrel).Yaw.Angle / 4; + Func muzzleFacing = () => MuzzleOrientation(self, barrel).Yaw; + var muzzleOrientation = WRot.FromYaw(muzzleFacing()); var passiveTarget = Weapon.TargetActorCenter ? target.CenterPosition : target.Positions.PositionClosestTo(muzzlePosition()); 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 initialOffset = new WVec(initialOffset.Y, -initialOffset.X, initialOffset.Z); - passiveTarget += initialOffset.Rotate(WRot.FromFacing(legacyFacing)); + passiveTarget += initialOffset.Rotate(muzzleOrientation); } 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 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 { Weapon = Weapon, - Facing = legacyFacing, - CurrentMuzzleFacing = legacyMuzzleFacing, + Facing = muzzleFacing(), + CurrentMuzzleFacing = muzzleFacing, DamageModifiers = damageModifiers.ToArray(), diff --git a/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs b/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs index 08d88f931c..bb6ce28b1c 100644 --- a/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs +++ b/OpenRA.Mods.Common/Traits/ThrowsShrapnel.cs @@ -68,8 +68,8 @@ namespace OpenRA.Mods.Common.Traits var args = new ProjectileArgs { Weapon = wep, - Facing = self.World.SharedRandom.Next(-1, 255), - CurrentMuzzleFacing = () => 0, + Facing = new WAngle(self.World.SharedRandom.Next(1024)), + CurrentMuzzleFacing = () => WAngle.Zero, DamageModifiers = self.TraitsImplementing() .Select(a => a.GetFirepowerModifier()).ToArray(), diff --git a/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs b/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs index 137a6c348f..857cd4cb2e 100644 --- a/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/FireClusterWarhead.cs @@ -76,7 +76,7 @@ namespace OpenRA.Mods.Common.Warheads var projectileArgs = new ProjectileArgs { Weapon = weapon, - Facing = (map.CenterOfCell(targetCell) - target.CenterPosition).Yaw.Facing, + Facing = (map.CenterOfCell(targetCell) - target.CenterPosition).Yaw, DamageModifiers = args.DamageModifiers, InaccuracyModifiers = new int[0], diff --git a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs index e56d47436a..6aed960a39 100644 --- a/OpenRA.Mods.D2k/Traits/SpiceBloom.cs +++ b/OpenRA.Mods.D2k/Traits/SpiceBloom.cs @@ -133,8 +133,8 @@ namespace OpenRA.Mods.D2k.Traits var args = new ProjectileArgs { Weapon = self.World.Map.Rules.Weapons[info.Weapon.ToLowerInvariant()], - Facing = 0, - CurrentMuzzleFacing = () => 0, + Facing = WAngle.Zero, + CurrentMuzzleFacing = () => WAngle.Zero, DamageModifiers = self.TraitsImplementing() .Select(a => a.GetFirepowerModifier()).ToArray(),