Merge pull request #11382 from reaperrr/projectile-streamlining

Moved projectiles to their own namespace and streamlined property names
This commit is contained in:
Oliver Brakmann
2016-06-04 15:00:08 +02:00
19 changed files with 82 additions and 56 deletions

View File

@@ -11,7 +11,7 @@
using System;
using System.Linq;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Projectiles;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;

View File

@@ -11,7 +11,7 @@
using System;
using System.Linq;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Projectiles;
using OpenRA.Mods.Common.Traits;
using OpenRA.Mods.Common.Warheads;
using OpenRA.Traits;

View File

@@ -147,21 +147,21 @@
<Compile Include="AI\States\StateBase.cs" />
<Compile Include="AI\SupportPowerDecision.cs" />
<Compile Include="Effects\Beacon.cs" />
<Compile Include="Effects\Bullet.cs" />
<Compile Include="Effects\Contrail.cs" />
<Compile Include="Effects\ContrailFader.cs" />
<Compile Include="Effects\CrateEffect.cs" />
<Compile Include="Effects\FlashTarget.cs" />
<Compile Include="Effects\FloatingText.cs" />
<Compile Include="Effects\GravityBomb.cs" />
<Compile Include="Effects\LaserZap.cs" />
<Compile Include="Effects\AreaBeam.cs" />
<Compile Include="Effects\Missile.cs" />
<Compile Include="Effects\NukeLaunch.cs" />
<Compile Include="Effects\PowerdownIndicator.cs" />
<Compile Include="Effects\RallyPointIndicator.cs" />
<Compile Include="Effects\RepairIndicator.cs" />
<Compile Include="Effects\SpriteEffect.cs" />
<Compile Include="Projectiles\AreaBeam.cs" />
<Compile Include="Projectiles\Bullet.cs" />
<Compile Include="Projectiles\GravityBomb.cs" />
<Compile Include="Projectiles\LaserZap.cs" />
<Compile Include="Projectiles\Missile.cs" />
<Compile Include="Commands\ChatCommands.cs" />
<Compile Include="Commands\DevCommands.cs" />
<Compile Include="Commands\HelpCommand.cs" />

View File

@@ -15,11 +15,12 @@ using System.Drawing;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects
namespace OpenRA.Mods.Common.Projectiles
{
public class AreaBeamInfo : IProjectileInfo
{

View File

@@ -15,11 +15,12 @@ using System.Drawing;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects
namespace OpenRA.Mods.Common.Projectiles
{
public class BulletInfo : IProjectileInfo
{
@@ -32,7 +33,7 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Image to display.")]
public readonly string Image = null;
[Desc("Loop these sequences of Image while this projectile is moving.")]
[Desc("Loop a randomly chosen sequence of Image from this list while this projectile is moving.")]
[SequenceReference("Image")] public readonly string[] Sequences = { "idle" };
[Desc("The palette used to draw this projectile.")]
@@ -45,10 +46,10 @@ namespace OpenRA.Mods.Common.Effects
[PaletteReference] public readonly string ShadowPalette = "shadow";
[Desc("Trail animation.")]
public readonly string Trail = null;
public readonly string TrailImage = null;
[Desc("Loop these sequences of Trail while this projectile is moving.")]
[SequenceReference("Trail")] public readonly string[] TrailSequences = { "idle" };
[Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")]
[SequenceReference("TrailImage")] public readonly string[] TrailSequences = { "idle" };
[Desc("Is this blocked by actors with BlocksProjectiles trait.")]
public readonly bool Blockable = true;
@@ -68,7 +69,10 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Delay in ticks until trail animation is spawned.")]
public readonly int TrailDelay = 1;
[Desc("Palette used to render the trail sequence.")]
[PaletteReference("TrailUsePlayerPalette")] public readonly string TrailPalette = "effect";
[Desc("Use the Player Palette to render the trail sequence.")]
public readonly bool TrailUsePlayerPalette = false;
public readonly int ContrailLength = 0;
@@ -179,11 +183,12 @@ namespace OpenRA.Mods.Common.Effects
shouldExplode = true;
}
if (!string.IsNullOrEmpty(info.Trail) && --smokeTicks < 0)
if (!string.IsNullOrEmpty(info.TrailImage) && --smokeTicks < 0)
{
var delayedPos = WPos.LerpQuadratic(args.Source, target, angle, ticks - info.TrailDelay, length);
world.AddFrameEndTask(w => w.Add(new SpriteEffect(delayedPos, w, info.Trail, info.TrailSequences.Random(world.SharedRandom),
world.AddFrameEndTask(w => w.Add(new SpriteEffect(delayedPos, w, info.TrailImage, info.TrailSequences.Random(world.SharedRandom),
trailPalette, false, false, GetEffectiveFacing())));
smokeTicks = info.TrailInterval;
}

View File

@@ -13,16 +13,17 @@ using System.Collections.Generic;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects
namespace OpenRA.Mods.Common.Projectiles
{
public class GravityBombInfo : IProjectileInfo
{
public readonly string Image = null;
[Desc("Sequence to loop while falling.")]
[SequenceReference("Image")] public readonly string Sequence = "idle";
[Desc("Loop a randomly chosen sequence of Image from this list while falling.")]
[SequenceReference("Image")] public readonly string[] Sequences = { "idle" };
[Desc("Sequence to play when launched. Skipped if null or empty.")]
[SequenceReference("Image")] public readonly string OpenSequence = null;
@@ -33,9 +34,9 @@ namespace OpenRA.Mods.Common.Effects
[PaletteReference] public readonly string ShadowPalette = "shadow";
public readonly WDist Velocity = WDist.Zero;
public readonly WDist Speed = WDist.Zero;
[Desc("Value added to velocity every tick.")]
[Desc("Value added to speed every tick.")]
public readonly WDist Acceleration = new WDist(15);
public IEffect Create(ProjectileArgs args) { return new GravityBomb(this, args); }
@@ -55,7 +56,7 @@ namespace OpenRA.Mods.Common.Effects
this.info = info;
this.args = args;
pos = args.Source;
velocity = new WVec(WDist.Zero, WDist.Zero, -info.Velocity);
velocity = new WVec(WDist.Zero, WDist.Zero, -info.Speed);
acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration);
if (!string.IsNullOrEmpty(info.Image))
@@ -63,9 +64,9 @@ namespace OpenRA.Mods.Common.Effects
anim = new Animation(args.SourceActor.World, info.Image);
if (!string.IsNullOrEmpty(info.OpenSequence))
anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequence));
anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom)));
else
anim.PlayRepeating(info.Sequence);
anim.PlayRepeating(info.Sequences.Random(args.SourceActor.World.SharedRandom));
}
}

View File

@@ -14,13 +14,14 @@ using System.Drawing;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects
namespace OpenRA.Mods.Common.Projectiles
{
[Desc("Not a sprite, but an engine effect.")]
class LaserZapInfo : IProjectileInfo
public class LaserZapInfo : IProjectileInfo
{
[Desc("The width of the zap.")]
public readonly WDist Width = new WDist(86);
@@ -53,7 +54,7 @@ namespace OpenRA.Mods.Common.Effects
}
}
class LaserZap : IEffect
public class LaserZap : IEffect
{
readonly ProjectileArgs args;
readonly LaserZapInfo info;

View File

@@ -16,20 +16,20 @@ using System.Linq;
using OpenRA.Effects;
using OpenRA.GameRules;
using OpenRA.Graphics;
using OpenRA.Mods.Common;
using OpenRA.Mods.Common.Effects;
using OpenRA.Mods.Common.Graphics;
using OpenRA.Mods.Common.Traits;
using OpenRA.Traits;
namespace OpenRA.Mods.Common.Effects
namespace OpenRA.Mods.Common.Projectiles
{
public class MissileInfo : IProjectileInfo
{
[Desc("Name of the image containing the projectile sequence.")]
public readonly string Image = null;
[Desc("Projectile sequence name.")]
[SequenceReference("Image")] public readonly string Sequence = "idle";
[Desc("Loop a randomly chosen sequence of Image from this list while this projectile is moving.")]
[SequenceReference("Image")] public readonly string[] Sequences = { "idle" };
[Desc("Palette used to render the projectile sequence.")]
[PaletteReference] public readonly string Palette = "effect";
@@ -100,19 +100,19 @@ namespace OpenRA.Mods.Common.Effects
[Desc("Image that contains the trail animation.")]
public readonly string TrailImage = null;
[Desc("Smoke sequence name.")]
[SequenceReference("TrailImage")] public readonly string TrailSequence = "idle";
[Desc("Loop a randomly chosen sequence of TrailImage from this list while this projectile is moving.")]
[SequenceReference("TrailImage")] public readonly string[] TrailSequences = { "idle" };
[Desc("Palette used to render the smoke sequence.")]
[Desc("Palette used to render the trail sequence.")]
[PaletteReference("TrailUsePlayerPalette")] public readonly string TrailPalette = "effect";
[Desc("Use the Player Palette to render the smoke sequence.")]
[Desc("Use the Player Palette to render the trail sequence.")]
public readonly bool TrailUsePlayerPalette = false;
[Desc("Interval in ticks between spawning smoke animation.")]
[Desc("Interval in ticks between spawning trail animation.")]
public readonly int TrailInterval = 2;
[Desc("Should smoke animation be spawned when the propulsion is not activated.")]
[Desc("Should trail animation be spawned when the propulsion is not activated.")]
public readonly bool TrailWhenDeactivated = false;
public readonly int ContrailLength = 0;
@@ -222,7 +222,7 @@ namespace OpenRA.Mods.Common.Effects
if (!string.IsNullOrEmpty(info.Image))
{
anim = new Animation(world, info.Image, () => renderFacing);
anim.PlayRepeating(info.Sequence);
anim.PlayRepeating(info.Sequences.Random(world.SharedRandom));
}
if (info.ContrailLength > 0)
@@ -817,10 +817,12 @@ namespace OpenRA.Mods.Common.Effects
shouldExplode = true;
}
// Create the smoke trail effect
// Create the sprite trail effect
if (!string.IsNullOrEmpty(info.TrailImage) && --ticksToNextSmoke < 0 && (state != States.Freefall || info.TrailWhenDeactivated))
{
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos - 3 * move / 2, w, info.TrailImage, info.TrailSequence, trailPalette, false, false, renderFacing)));
world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos - 3 * move / 2, w, info.TrailImage, info.TrailSequences.Random(world.SharedRandom),
trailPalette, false, false, renderFacing)));
ticksToNextSmoke = info.TrailInterval;
}

View File

@@ -159,6 +159,22 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
// Streamline some projectile property names and functionality
if (engineVersion < 20160601)
{
if (node.Key == "Sequence")
node.Key = "Sequences";
if (node.Key == "TrailSequence")
node.Key = "TrailSequences";
if (node.Key == "Trail")
node.Key = "TrailImage";
if (node.Key == "Velocity")
node.Key = "Speed";
}
UpgradeWeaponRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}

View File

@@ -82,7 +82,7 @@
<Compile Include="Effects\GpsDot.cs" />
<Compile Include="Effects\GpsSatellite.cs" />
<Compile Include="Effects\SatelliteLaunch.cs" />
<Compile Include="Effects\TeslaZap.cs" />
<Compile Include="Projectiles\TeslaZap.cs" />
<Compile Include="Graphics\TeslaZapRenderable.cs" />
<Compile Include="Scripting\Properties\InfiltrateProperties.cs" />
<Compile Include="Scripting\Properties\DisguiseProperties.cs" />

View File

@@ -16,9 +16,9 @@ using OpenRA.Graphics;
using OpenRA.Mods.RA.Graphics;
using OpenRA.Traits;
namespace OpenRA.Mods.RA.Effects
namespace OpenRA.Mods.RA.Projectiles
{
class TeslaZapInfo : IProjectileInfo
public class TeslaZapInfo : IProjectileInfo
{
public readonly string Image = "litning";
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.RA.Effects
public IEffect Create(ProjectileArgs args) { return new TeslaZap(this, args); }
}
class TeslaZap : IEffect
public class TeslaZap : IEffect
{
readonly ProjectileArgs args;
readonly TeslaZapInfo info;

View File

@@ -184,7 +184,7 @@ MammothMissiles:
Image: DRAGON
RateOfTurn: 2
ContrailLength: 10
Trail: smokey
TrailImage: smokey
Speed: 341
Warhead@1Dam: SpreadDamage
Spread: 683
@@ -342,7 +342,7 @@ HonestJohn:
Shadow: true
Inaccuracy: 213
Image: patriot
Trail: smokey
TrailImage: smokey
Speed: 187
RangeLimit: 35
Angle: 88

View File

@@ -38,7 +38,7 @@ Debris2:
Angle: 30, 90
Inaccuracy: 1c256
Image: shrapnel2
Trail: bazooka_trail
TrailImage: bazooka_trail
TrailPalette: effect75alpha
TrailInterval: 2
Warhead@1Dam: SpreadDamage
@@ -72,7 +72,7 @@ Debris3:
Angle: 30, 90
Inaccuracy: 1c256
Image: shrapnel3
Trail: large_trail
TrailImage: large_trail
TrailPalette: effect75alpha
TrailInterval: 1
Warhead@1Dam: SpreadDamage
@@ -106,7 +106,7 @@ Debris4:
Angle: 30, 90
Inaccuracy: 1c256
Image: shrapnel4
Trail: large_trail
TrailImage: large_trail
TrailPalette: effect75alpha
TrailInterval: 1
Warhead@1Dam: SpreadDamage

View File

@@ -265,7 +265,7 @@ SpiceExplosion:
Speed: 50, 75
Blockable: false
Angle: 60, 90
Trail: large_trail
TrailImage: large_trail
Image: 120mm
Warhead@1Dam: SpreadDamage
Spread: 320

View File

@@ -41,7 +41,7 @@ SubMissile:
Angle: 62
Inaccuracy: 2c938
Image: MISSILE
Trail: smokey
TrailImage: smokey
ContrailLength: 30
Warhead: SpreadDamage
Spread: 426

View File

@@ -27,7 +27,7 @@ FireballLauncherInterior:
BurstDelay: 20
Projectile: Bullet
Speed: 204
Trail: fb2
TrailImage: fb2
Image: FB1
Warhead@1Dam: SpreadDamage
Spread: 213

View File

@@ -256,7 +256,7 @@ SubMissile:
Angle: 165
Inaccuracy: 2c938
Image: MISSILE
Trail: smokey
TrailImage: smokey
ContrailLength: 30
Warhead@1Dam: SpreadDamage
Spread: 426
@@ -409,7 +409,7 @@ SCUD:
Speed: 170
Blockable: false
Shadow: false
Trail: smokey
TrailImage: smokey
TrailDelay: 5
Inaccuracy: 213
Image: V2

View File

@@ -6,7 +6,7 @@ FireballLauncher:
BurstDelay: 20
Projectile: Bullet
Speed: 204
Trail: fb2
TrailImage: fb2
Image: FB1
Warhead@1Dam: SpreadDamage
Spread: 213
@@ -33,7 +33,7 @@ Flamer:
BurstDelay: 1
Projectile: Bullet
Speed: 170
Trail: fb4
TrailImage: fb4
Image: fb3
Angle: 62
Inaccuracy: 853

View File

@@ -5,7 +5,7 @@ ParaBomb:
Projectile: GravityBomb
Image: PARABOMB
OpenSequence: open
Velocity: 86
Speed: 86
Acceleration: 0
Warhead@1Dam: SpreadDamage
Spread: 768