diff --git a/OpenRa.Game/Bullet.cs b/OpenRa.Game/Bullet.cs index c381c65e99..0eacf93c17 100644 --- a/OpenRa.Game/Bullet.cs +++ b/OpenRa.Game/Bullet.cs @@ -72,20 +72,36 @@ namespace OpenRa.Game { Game.world.AddFrameEndTask(w => { - w.Remove(this); + w.Remove(this); - var isWater = Game.IsCellBuildable( - ((1f / Game.CellSize) * Dest.ToFloat2()).ToInt2(), UnitMovementType.Float); + var targetTile = ((1f / Game.CellSize) * Dest.ToFloat2()).ToInt2(); + + var isWater = Game.IsWater(targetTile); + var hitWater = Game.IsCellBuildable(targetTile, UnitMovementType.Float); if (Warhead.Explosion != 0) - w.Add(new Explosion(VisualDest, Warhead.Explosion, isWater)); + w.Add(new Explosion(VisualDest, Warhead.Explosion, hitWater)); var impact = Warhead.ImpactSound; - if (isWater && Warhead.WaterImpactSound != null) + if (hitWater && Warhead.WaterImpactSound != null) impact = Warhead.WaterImpactSound; if (impact != null) Game.PlaySound(impact+ ".aud", false); + + if (!isWater) + switch( Warhead.Explosion ) /* todo: push the scorch/crater behavior into data */ + { + case 4: + case 5: + Smudge.AddSmudge(true, targetTile.X, targetTile.Y); + break; + + case 3: + case 6: + Smudge.AddSmudge(false, targetTile.X, targetTile.Y); + break; + } }); var maxSpread = GetMaximumSpread(); diff --git a/OpenRa.Game/Graphics/OverlayRenderer.cs b/OpenRa.Game/Graphics/OverlayRenderer.cs index ad3a00efb1..0df11be438 100755 --- a/OpenRa.Game/Graphics/OverlayRenderer.cs +++ b/OpenRa.Game/Graphics/OverlayRenderer.cs @@ -33,8 +33,8 @@ namespace OpenRa.Game.Graphics for (int i = 0; i < overlaySpriteNames.Length; i++) overlaySprites[i] = SpriteSheetBuilder.LoadAllSprites(overlaySpriteNames[i], ".shp", ".tem", ".sno"); - /* todo: add the rest of the smudge sprites */ - smudgeSprites = new[] { "bib3", "bib2" }.SelectMany( + smudgeSprites = new[] { "bib3", "bib2", "sc1", "sc2", "sc3", "sc4", "sc5", "sc6", + "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", }.SelectMany( f => SpriteSheetBuilder.LoadAllSprites(f, ".shp", ".tem", ".sno")).ToArray(); } diff --git a/OpenRa.Game/OpenRa.Game.csproj b/OpenRa.Game/OpenRa.Game.csproj index 15aab4907a..97009a120c 100644 --- a/OpenRa.Game/OpenRa.Game.csproj +++ b/OpenRa.Game/OpenRa.Game.csproj @@ -91,6 +91,7 @@ + diff --git a/OpenRa.Game/Smudge.cs b/OpenRa.Game/Smudge.cs new file mode 100644 index 0000000000..85109fd76f --- /dev/null +++ b/OpenRa.Game/Smudge.cs @@ -0,0 +1,33 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace OpenRa.Game +{ + static class Smudge + { + const int firstScorch = 11; + const int firstCrater = 17; + const int framesPerCrater = 5; + + public static void AddSmudge(bool isCrater, int x, int y) + { + var smudge = Rules.Map.MapTiles[x, y].smudge; + if (smudge == 0) + Rules.Map.MapTiles[x, y].smudge = (byte) (isCrater + ? (firstCrater + framesPerCrater * ChooseSmudge()) + : (firstScorch + ChooseSmudge())); + + if (smudge < firstCrater || !isCrater) return; /* bib or scorch; don't change */ + + /* deepen the crater */ + var amount = (smudge - firstCrater) % framesPerCrater; + if (amount < framesPerCrater - 1) + Rules.Map.MapTiles[x, y].smudge++; + } + + static int lastSmudge = 0; + static int ChooseSmudge() { lastSmudge = (lastSmudge + 1) % 6; return lastSmudge; } + } +}