move Combat, AttackBase, and associates into mod

This commit is contained in:
Bob
2010-07-08 16:32:25 +12:00
parent bd74b29ea3
commit 281d013c3b
20 changed files with 95 additions and 91 deletions

View File

@@ -24,7 +24,7 @@ using OpenRA.Traits;
namespace OpenRA.Effects namespace OpenRA.Effects
{ {
class FlashTarget : IEffect public class FlashTarget : IEffect
{ {
Actor target; Actor target;
int remainingTicks = 4; int remainingTicks = 4;

View File

@@ -21,9 +21,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using OpenRA.GameRules;
using OpenRA.Traits;
using OpenRA.Support; using OpenRA.Support;
using OpenRA.Traits;
namespace OpenRA namespace OpenRA
{ {
@@ -45,28 +44,6 @@ namespace OpenRA
return xs.Aggregate(1f, (a, x) => a * x); return xs.Aggregate(1f, (a, x) => a * x);
} }
public static WeaponInfo GetPrimaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.PrimaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
public static WeaponInfo GetSecondaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.SecondaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
public static int GetMaxHP(this Actor self) public static int GetMaxHP(this Actor self)
{ {
var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>(); var oai = self.Info.Traits.GetOrDefault<OwnedActorInfo>();

View File

@@ -89,7 +89,6 @@
<Compile Include="Traits\Modifiers\HiddenUnderFog.cs" /> <Compile Include="Traits\Modifiers\HiddenUnderFog.cs" />
<Compile Include="Traits\Render\RenderBuilding.cs" /> <Compile Include="Traits\Render\RenderBuilding.cs" />
<Compile Include="Traits\Render\RenderBuildingTurreted.cs" /> <Compile Include="Traits\Render\RenderBuildingTurreted.cs" />
<Compile Include="Traits\Render\RenderUnitTurreted.cs" />
<Compile Include="Traits\World\Shroud.cs" /> <Compile Include="Traits\World\Shroud.cs" />
<Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" /> <Compile Include="Widgets\Delegates\ConnectionDialogsDelegate.cs" />
<Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" /> <Compile Include="Widgets\Delegates\CreateServerMenuDelegate.cs" />
@@ -102,7 +101,6 @@
<Compile Include="Widgets\MapPreviewWidget.cs" /> <Compile Include="Widgets\MapPreviewWidget.cs" />
<Compile Include="Widgets\PostGameWidget.cs" /> <Compile Include="Widgets\PostGameWidget.cs" />
<Compile Include="Widgets\WidgetUtils.cs" /> <Compile Include="Widgets\WidgetUtils.cs" />
<Compile Include="Combat.cs" />
<Compile Include="Effects\DelayedAction.cs" /> <Compile Include="Effects\DelayedAction.cs" />
<Compile Include="Effects\FlashTarget.cs" /> <Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\MoveFlash.cs" /> <Compile Include="Effects\MoveFlash.cs" />
@@ -136,7 +134,6 @@
<Compile Include="Traits\World\SpatialBins.cs" /> <Compile Include="Traits\World\SpatialBins.cs" />
<Compile Include="Traits\World\ChoosePaletteOnSelect.cs" /> <Compile Include="Traits\World\ChoosePaletteOnSelect.cs" />
<Compile Include="Traits\World\Country.cs" /> <Compile Include="Traits\World\Country.cs" />
<Compile Include="Traits\Activities\Attack.cs" />
<Compile Include="Traits\Activities\TransformIntoActor.cs" /> <Compile Include="Traits\Activities\TransformIntoActor.cs" />
<Compile Include="Actor.cs" /> <Compile Include="Actor.cs" />
<Compile Include="Controller.cs" /> <Compile Include="Controller.cs" />
@@ -175,7 +172,6 @@
<Compile Include="Graphics\TerrainRenderer.cs" /> <Compile Include="Graphics\TerrainRenderer.cs" />
<Compile Include="Traits\Activities\Move.cs" /> <Compile Include="Traits\Activities\Move.cs" />
<Compile Include="Traits\Activities\Turn.cs" /> <Compile Include="Traits\Activities\Turn.cs" />
<Compile Include="Traits\AttackBase.cs" />
<Compile Include="Traits\Buildable.cs" /> <Compile Include="Traits\Buildable.cs" />
<Compile Include="Traits\Building.cs" /> <Compile Include="Traits\Building.cs" />
<Compile Include="Traits\World\BuildingInfluence.cs" /> <Compile Include="Traits\World\BuildingInfluence.cs" />
@@ -235,7 +231,6 @@
<Compile Include="Traits\SharesCell.cs" /> <Compile Include="Traits\SharesCell.cs" />
<Compile Include="Traits\World\AircraftInfluence.cs" /> <Compile Include="Traits\World\AircraftInfluence.cs" />
<Compile Include="Traits\World\HazardLayer.cs" /> <Compile Include="Traits\World\HazardLayer.cs" />
<Compile Include="Traits\Hazardous.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj"> <ProjectReference Include="..\OpenRA.FileFormats\OpenRA.FileFormats.csproj">

View File

@@ -52,9 +52,9 @@ namespace OpenRA.Orders
world.WorldRenderer.DrawSelectionBox(a, Color.White, true); world.WorldRenderer.DrawSelectionBox(a, Color.White, true);
if (a.Owner == world.LocalPlayer) if (a.Owner == world.LocalPlayer)
{ {
if (a.traits.Contains<RenderRangeCircle>()) //if (a.traits.Contains<RenderRangeCircle>())
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow), // world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.Yellow),
a.CenterLocation, (int)a.GetPrimaryWeapon().Range); // a.CenterLocation, (int)a.GetPrimaryWeapon().Range);
if (a.traits.Contains<DetectCloaked>()) if (a.traits.Contains<DetectCloaked>())
world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen), world.WorldRenderer.DrawRangeCircle(Color.FromArgb(128, Color.LimeGreen),

View File

@@ -21,7 +21,6 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using OpenRA.GameRules;
using OpenRA.Graphics; using OpenRA.Graphics;
namespace OpenRA.Traits namespace OpenRA.Traits
@@ -82,7 +81,7 @@ namespace OpenRA.Traits
return a / step; return a / step;
} }
static float2 RotateVectorByFacing(float2 v, int facing, float ecc) public static float2 RotateVectorByFacing(float2 v, int facing, float ecc)
{ {
var angle = (facing / 256f) * (2 * (float)Math.PI); var angle = (facing / 256f) * (2 * (float)Math.PI);
var sinAngle = (float)Math.Sin(angle); var sinAngle = (float)Math.Sin(angle);
@@ -93,17 +92,6 @@ namespace OpenRA.Traits
ecc * (cosAngle * v.Y - sinAngle * v.X)); ecc * (cosAngle * v.Y - sinAngle * v.X));
} }
static float2 GetRecoil(Actor self, float recoil)
{
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (abInfo == null || abInfo.Recoil == 0) return float2.Zero;
var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
if (rut == null) return float2.Zero;
var facing = self.traits.Get<Turreted>().turretFacing;
return RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get<AttackBaseInfo>().Recoil), facing, .7f);
}
public static float2 CenterOfCell(int2 loc) public static float2 CenterOfCell(int2 loc)
{ {
return new float2(12, 12) + Game.CellSize * (float2)loc; return new float2(12, 12) + Game.CellSize * (float2)loc;
@@ -114,19 +102,6 @@ namespace OpenRA.Traits
return 0.5f * (CenterOfCell(from) + CenterOfCell(to)); return 0.5f * (CenterOfCell(from) + CenterOfCell(to));
} }
public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil)
{
if( unit == null ) return offset.AbsOffset(); /* things that don't have a rotating base don't need the turrets repositioned */
var ru = self.traits.GetOrDefault<RenderUnit>();
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
var bodyFacing = unit.Facing;
var quantizedFacing = QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
return (RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil))
+ offset.AbsOffset();
}
public static int2 AsInt2(this int[] xs) { return new int2(xs[0], xs[1]); } public static int2 AsInt2(this int[] xs) { return new int2(xs[0], xs[1]); }
public static float2 RelOffset(this int[] offset) { return new float2(offset[0], offset[1]); } public static float2 RelOffset(this int[] offset) { return new float2(offset[0], offset[1]); }
public static float2 AbsOffset(this int[] offset) { return new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); } public static float2 AbsOffset(this int[] offset) { return new float2(offset.ElementAtOrDefault(2), offset.ElementAtOrDefault(3)); }
@@ -144,12 +119,6 @@ namespace OpenRA.Traits
(next, a) => { a.NextActivity = next; return a; }); (next, a) => { a.NextActivity = next; return a; });
} }
public static float GetMaximumRange(Actor self)
{
return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() }
.Where(w => w != null).Max(w => w.Range);
}
public static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2]); } public static Color ArrayToColor(int[] x) { return Color.FromArgb(x[0], x[1], x[2]); }
public static int2 CellContaining(float2 pos) { return (1f / Game.CellSize * pos).ToInt2(); } public static int2 CellContaining(float2 pos) { return (1f / Game.CellSize * pos).ToInt2(); }

View File

@@ -26,7 +26,7 @@ using OpenRA.FileFormats;
namespace OpenRA.Traits namespace OpenRA.Traits
{ {
class SmudgeLayerInfo : ITraitInfo public class SmudgeLayerInfo : ITraitInfo
{ {
public readonly string Type = "Scorch"; public readonly string Type = "Scorch";
public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"}; public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"};
@@ -34,7 +34,7 @@ namespace OpenRA.Traits
public object Create(ActorInitializer init) { return new SmudgeLayer(this); } public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
} }
class SmudgeLayer: IRenderOverlay, ILoadWorldHook public class SmudgeLayer: IRenderOverlay, ILoadWorldHook
{ {
public SmudgeLayerInfo Info; public SmudgeLayerInfo Info;
SpriteRenderer spriteRenderer; SpriteRenderer spriteRenderer;

View File

@@ -18,10 +18,10 @@
*/ */
#endregion #endregion
using System;
using System.Collections.Generic; using System.Collections.Generic;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.RA;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Cnc.Effects namespace OpenRA.Mods.Cnc.Effects

View File

@@ -20,6 +20,7 @@
using System.Linq; using System.Linq;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Mods.RA;
using OpenRA.Traits; using OpenRA.Traits;
namespace OpenRA.Mods.Cnc namespace OpenRA.Mods.Cnc

View File

@@ -18,7 +18,10 @@
*/ */
#endregion #endregion
namespace OpenRA.Traits.Activities using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA.Activities
{ {
/* non-turreted attack */ /* non-turreted attack */
public class Attack : IActivity public class Attack : IActivity

View File

@@ -24,8 +24,9 @@ using System.Linq;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.FileFormats; using OpenRA.FileFormats;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits;
namespace OpenRA.Traits namespace OpenRA.Mods.RA
{ {
public class AttackBaseInfo : ITraitInfo public class AttackBaseInfo : ITraitInfo
{ {
@@ -178,7 +179,7 @@ namespace OpenRA.Traits
firedBy = self, firedBy = self,
target = target, target = target,
src = self.CenterLocation.ToInt2() + Util.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(), src = self.CenterLocation.ToInt2() + Combat.GetTurretPosition(self, unit, fireOffset, 0f).ToInt2(),
srcAltitude = unit != null ? unit.Altitude : 0, srcAltitude = unit != null ? unit.Altitude : 0,
dest = target.CenterLocation.ToInt2(), dest = target.CenterLocation.ToInt2(),
destAltitude = destUnit != null ? destUnit.Altitude : 0, destAltitude = destUnit != null ? destUnit.Altitude : 0,

View File

@@ -19,8 +19,8 @@
#endregion #endregion
using System.Linq; using System.Linq;
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
bool NeedsNewTarget(Actor self) bool NeedsNewTarget(Actor self)
{ {
var attack = self.traits.Get<AttackBase>(); var attack = self.traits.Get<AttackBase>();
var range = Util.GetMaximumRange(self); var range = Combat.GetMaximumRange(self);
if (attack.target == null) if (attack.target == null)
return true; // he's dead. return true; // he's dead.
@@ -55,7 +55,7 @@ namespace OpenRA.Mods.RA
public void Tick(Actor self) public void Tick(Actor self)
{ {
var range = Util.GetMaximumRange(self); var range = Combat.GetMaximumRange(self);
if (NeedsNewTarget(self)) if (NeedsNewTarget(self))
AttackTarget(self, ChooseTarget(self, range)); AttackTarget(self, ChooseTarget(self, range));

View File

@@ -48,7 +48,7 @@ namespace OpenRA.Mods.RA
if (--nextScanTime <= 0) if (--nextScanTime <= 0)
{ {
var attack = self.traits.Get<AttackBase>(); var attack = self.traits.Get<AttackBase>();
var range = Util.GetMaximumRange(self); var range = Combat.GetMaximumRange(self);
if (attack.target == null || if (attack.target == null ||
(attack.target.Location - self.Location).LengthSquared > range * range) (attack.target.Location - self.Location).LengthSquared > range * range)

55
OpenRA.Game/Combat.cs → OpenRA.Mods.RA/Combat.cs Normal file → Executable file
View File

@@ -23,9 +23,8 @@ using System.Linq;
using OpenRA.Effects; using OpenRA.Effects;
using OpenRA.GameRules; using OpenRA.GameRules;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.FileFormats;
namespace OpenRA namespace OpenRA.Mods.RA
{ {
public static class Combat /* some utility bits that are shared between various things */ public static class Combat /* some utility bits that are shared between various things */
{ {
@@ -194,5 +193,57 @@ namespace OpenRA
return false; return false;
} }
public static float GetMaximumRange(Actor self)
{
return new[] { self.GetPrimaryWeapon(), self.GetSecondaryWeapon() }
.Where(w => w != null).Max(w => w.Range);
}
public static WeaponInfo GetPrimaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.PrimaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
public static WeaponInfo GetSecondaryWeapon(this Actor self)
{
var info = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (info == null) return null;
var weapon = info.SecondaryWeapon;
if (weapon == null) return null;
return Rules.Weapons[weapon.ToLowerInvariant()];
}
static float2 GetRecoil(Actor self, float recoil)
{
var abInfo = self.Info.Traits.GetOrDefault<AttackBaseInfo>();
if (abInfo == null || abInfo.Recoil == 0) return float2.Zero;
var rut = self.traits.GetOrDefault<RenderUnitTurreted>();
if (rut == null) return float2.Zero;
var facing = self.traits.Get<Turreted>().turretFacing;
return Util.RotateVectorByFacing(new float2(0, recoil * self.Info.Traits.Get<AttackBaseInfo>().Recoil), facing, .7f);
}
public static float2 GetTurretPosition(Actor self, Unit unit, int[] offset, float recoil)
{
if( unit == null ) return offset.AbsOffset(); /* things that don't have a rotating base don't need the turrets repositioned */
var ru = self.traits.GetOrDefault<RenderUnit>();
var numDirs = (ru != null) ? ru.anim.CurrentSequence.Facings : 8;
var bodyFacing = unit.Facing;
var quantizedFacing = Util.QuantizeFacing(bodyFacing, numDirs) * (256 / numDirs);
return (Util.RotateVectorByFacing(offset.RelOffset(), quantizedFacing, .7f) + GetRecoil(self, recoil))
+ offset.AbsOffset();
}
} }
} }

View File

@@ -16,12 +16,13 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>. * along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/ */
#endregion #endregion
using System.Collections.Generic;
using System.Linq;
using OpenRA.Traits;
using System.Linq; namespace OpenRA.Mods.RA
using System.Collections.Generic;
namespace OpenRA.Traits
{ {
class AntiAirInfo : ITraitInfo class AntiAirInfo : ITraitInfo
{ {

View File

@@ -46,6 +46,7 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Activities\Attack.cs" />
<Compile Include="Activities\CallFunc.cs" /> <Compile Include="Activities\CallFunc.cs" />
<Compile Include="Activities\CaptureBuilding.cs" /> <Compile Include="Activities\CaptureBuilding.cs" />
<Compile Include="Activities\DeliverOre.cs" /> <Compile Include="Activities\DeliverOre.cs" />
@@ -70,14 +71,18 @@
<Compile Include="Activities\UndeployMcv.cs" /> <Compile Include="Activities\UndeployMcv.cs" />
<Compile Include="Activities\UnloadCargo.cs" /> <Compile Include="Activities\UnloadCargo.cs" />
<Compile Include="Activities\Wait.cs" /> <Compile Include="Activities\Wait.cs" />
<Compile Include="AttackBase.cs" />
<Compile Include="Combat.cs" />
<Compile Include="ConstructionYard.cs" /> <Compile Include="ConstructionYard.cs" />
<Compile Include="Effects\Bullet.cs" /> <Compile Include="Effects\Bullet.cs" />
<Compile Include="Effects\GravityBomb.cs" /> <Compile Include="Effects\GravityBomb.cs" />
<Compile Include="Effects\LaserZap.cs" /> <Compile Include="Effects\LaserZap.cs" />
<Compile Include="Effects\Missile.cs" /> <Compile Include="Effects\Missile.cs" />
<Compile Include="Effects\TeslaZap.cs" /> <Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Hazardous.cs" />
<Compile Include="Player\ActorGroupProxy.cs" /> <Compile Include="Player\ActorGroupProxy.cs" />
<Compile Include="Aircraft.cs" /> <Compile Include="Aircraft.cs" />
<Compile Include="RenderUnitTurreted.cs" />
<Compile Include="SupportPowers\AirstrikePower.cs" /> <Compile Include="SupportPowers\AirstrikePower.cs" />
<Compile Include="AttackFrontal.cs" /> <Compile Include="AttackFrontal.cs" />
<Compile Include="AttackHeli.cs" /> <Compile Include="AttackHeli.cs" />

View File

@@ -18,8 +18,8 @@
*/ */
#endregion #endregion
using OpenRA.Mods.RA.Activities;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Traits.Activities;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.RA
rotorAnim.PlayRepeating("rotor"); rotorAnim.PlayRepeating("rotor");
anims.Add( "rotor_1", new AnimationWithOffset( anims.Add( "rotor_1", new AnimationWithOffset(
rotorAnim, rotorAnim,
() => Traits.Util.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ), () => Combat.GetTurretPosition( self, unit, info.PrimaryOffset, 0 ),
null ) { ZOffset = 1 } ); null ) { ZOffset = 1 } );
if (info.SecondaryOffset == null) return; if (info.SecondaryOffset == null) return;
@@ -54,7 +54,7 @@ namespace OpenRA.Mods.RA
secondRotorAnim.PlayRepeating( "rotor2" ); secondRotorAnim.PlayRepeating( "rotor2" );
anims.Add( "rotor_2", new AnimationWithOffset( anims.Add( "rotor_2", new AnimationWithOffset(
secondRotorAnim, secondRotorAnim,
() => Traits.Util.GetTurretPosition(self, unit, info.SecondaryOffset, 0), () => Combat.GetTurretPosition(self, unit, info.SecondaryOffset, 0),
null) { ZOffset = 1 }); null) { ZOffset = 1 });
} }

View File

@@ -41,7 +41,7 @@ namespace OpenRA.Mods.RA
spinnerAnim.PlayRepeating( "spinner" ); spinnerAnim.PlayRepeating( "spinner" );
anims.Add( "spinner", new AnimationWithOffset( anims.Add( "spinner", new AnimationWithOffset(
spinnerAnim, spinnerAnim,
() => Traits.Util.GetTurretPosition( self, unit, info.Offset, 0 ), () => Combat.GetTurretPosition( self, unit, info.Offset, 0 ),
null ) { ZOffset = 1 } ); null ) { ZOffset = 1 } );
} }
} }

View File

@@ -19,8 +19,9 @@
#endregion #endregion
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Traits namespace OpenRA.Mods.RA
{ {
class RenderUnitTurretedInfo : RenderUnitInfo class RenderUnitTurretedInfo : RenderUnitInfo
{ {
@@ -43,13 +44,13 @@ namespace OpenRA.Traits
if( attackInfo.PrimaryOffset != null ) if( attackInfo.PrimaryOffset != null )
anims.Add("turret_1", new AnimationWithOffset( anims.Add("turret_1", new AnimationWithOffset(
turretAnim, turretAnim,
() => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil), () => Combat.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
null) { ZOffset = 1 }); null) { ZOffset = 1 });
if (attackInfo.SecondaryOffset != null) if (attackInfo.SecondaryOffset != null)
anims.Add("turret_2", new AnimationWithOffset( anims.Add("turret_2", new AnimationWithOffset(
turretAnim, turretAnim,
() => Util.GetTurretPosition(self, unit, attackInfo.SecondaryOffset, attack.secondaryRecoil), () => Combat.GetTurretPosition(self, unit, attackInfo.SecondaryOffset, attack.secondaryRecoil),
null) { ZOffset = 1 }); null) { ZOffset = 1 });
if( attackInfo.MuzzleFlash ) if( attackInfo.MuzzleFlash )
@@ -59,7 +60,7 @@ namespace OpenRA.Traits
() => (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */ () => (int)( attack.primaryRecoil * 5.9f ) ); /* hack: recoil can be 1.0f, but don't overflow into next anim */
anims.Add( "muzzle_flash", new AnimationWithOffset( anims.Add( "muzzle_flash", new AnimationWithOffset(
muzzleFlash, muzzleFlash,
() => Util.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil), () => Combat.GetTurretPosition(self, unit, attackInfo.PrimaryOffset, attack.primaryRecoil),
() => attack.primaryRecoil <= 0 ) ); () => attack.primaryRecoil <= 0 ) );
} }
} }

View File

@@ -57,7 +57,7 @@ namespace OpenRA.Mods.RA
if (info != null) if (info != null)
{ {
alt = 0; alt = 0;
pos = Traits.Util.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0); pos = Combat.GetTurretPosition(self, self.traits.Get<Unit>(), info.Offset, 0);
var ru = self.traits.Get<RenderUnit>(); var ru = self.traits.Get<RenderUnit>();
v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset(); v = Game.CosmeticRandom.Gauss2D(1) * info.Spread.RelOffset();