diff --git a/OpenRA.Game/Combat.cs b/OpenRA.Game/Combat.cs index 5c2de3bb14..78605b22ca 100644 --- a/OpenRA.Game/Combat.cs +++ b/OpenRA.Game/Combat.cs @@ -51,8 +51,14 @@ namespace OpenRA w => w.Add(new Explosion(w, visualLocation, warhead.Explosion, isWater))); Sound.Play(GetImpactSound(warhead, isWater)); - - if (!isWater) world.Map.AddSmudge(targetTile, warhead); + + if (warhead.SmudgeType != SmudgeType.None) + { + var smudgeLayer = world.WorldActor.traits.WithInterface().FirstOrDefault(x => x.Info.Type == warhead.SmudgeType); + if (!isWater) + smudgeLayer.AddSmudge(targetTile); + } + if (warhead.Ore) world.WorldActor.traits.Get().Destroy(targetTile); diff --git a/OpenRA.Game/Graphics/SmudgeRenderer.cs b/OpenRA.Game/Graphics/SmudgeRenderer.cs deleted file mode 100644 index a97dfb8f8d..0000000000 --- a/OpenRA.Game/Graphics/SmudgeRenderer.cs +++ /dev/null @@ -1,70 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using System.Linq; -using OpenRA.FileFormats; - -namespace OpenRA.Graphics -{ - class SmudgeRenderer - { - static string[] smudgeSpriteNames = - { - "bib3", "bib2", "bib1", "sc1", "sc2", "sc3", "sc4", "sc5", "sc6", - "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", - }; - - readonly Sprite[] smudgeSprites; - - SpriteRenderer spriteRenderer; - Map map; - - public SmudgeRenderer( Renderer renderer, Map map ) - { - this.spriteRenderer = new SpriteRenderer( renderer, true ); - this.map = map; - - smudgeSprites = smudgeSpriteNames.SelectMany(f => SpriteSheetBuilder.LoadAllSprites(f)).ToArray(); - } - - public void Draw() - { - /* - var shroud = Game.world.LocalPlayer.Shroud; - - for (int y = map.YOffset; y < map.YOffset + map.Height; y++) - for (int x = map.XOffset; x < map.XOffset + map.Width; x++) - { - if (!shroud.IsExplored(new int2(x,y))) continue; - - var tr = map.MapTiles[x,y]; - if (tr.smudge != 0 && tr.smudge <= smudgeSprites.Length) - { - var location = new int2(x, y); - spriteRenderer.DrawSprite(smudgeSprites[tr.smudge - 1], - Game.CellSize * (float2)location, "terrain"); - } - } - - spriteRenderer.Flush(); - */ - } - } -} diff --git a/OpenRA.Game/Graphics/TerrainRenderer.cs b/OpenRA.Game/Graphics/TerrainRenderer.cs index b0c5932d54..5ccc5c4610 100644 --- a/OpenRA.Game/Graphics/TerrainRenderer.cs +++ b/OpenRA.Game/Graphics/TerrainRenderer.cs @@ -33,7 +33,6 @@ namespace OpenRA.Graphics Renderer renderer; Map map; - SmudgeRenderer overlayRenderer; public TerrainRenderer(World world, Renderer renderer, WorldRenderer wr) { @@ -68,8 +67,6 @@ namespace OpenRA.Graphics indexBuffer = renderer.Device.CreateIndexBuffer( indices.Length ); indexBuffer.SetData( indices ); - - overlayRenderer = new SmudgeRenderer( renderer, map ); } public void Draw( Viewport viewport ) @@ -109,8 +106,6 @@ namespace OpenRA.Graphics foreach (var r in Game.world.WorldActor.traits.WithInterface()) r.Render(); - - overlayRenderer.Draw(); } } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index f4b3816aac..c37aae5b8b 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -65,11 +65,11 @@ - + False ..\thirdparty\Tao\Tao.FreeType.dll - + False ..\thirdparty\Tao\Tao.OpenAl.dll @@ -122,7 +122,6 @@ - @@ -159,7 +158,6 @@ - @@ -293,6 +291,7 @@ + diff --git a/OpenRA.Game/Smudge.cs b/OpenRA.Game/Smudge.cs deleted file mode 100644 index 64b8f40a4e..0000000000 --- a/OpenRA.Game/Smudge.cs +++ /dev/null @@ -1,67 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. - * This file is part of OpenRA. - * - * OpenRA is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * OpenRA is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenRA. If not, see . - */ -#endregion - -using OpenRA.FileFormats; -using OpenRA.GameRules; - -namespace OpenRA -{ - static class Smudge - { - const int firstScorch = 19; - const int firstCrater = 25; - const int framesPerCrater = 5; - - public static void AddSmudge(this Map map, bool isCrater, int x, int y) - { - /* - var smudge = map.MapTiles[x, y].smudge; - if (smudge == 0) - 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) - map.MapTiles[x, y].smudge++; - */ - } - - public static void AddSmudge(this Map map, int2 targetTile, WarheadInfo warhead) - { - /* - if (warhead.SmudgeType == SmudgeType.None) return; - if (warhead.Size[0] == 0 && warhead.Size[1] == 0) - map.AddSmudge(warhead.SmudgeType == SmudgeType.Crater, targetTile.X, targetTile.Y); - else - foreach (var t in Game.world.FindTilesInCircle(targetTile, warhead.Size[0])) - if ((t - targetTile).LengthSquared >= warhead.Size[1] * warhead.Size[1]) - if (Rules.TerrainTypes[Game.world.GetTerrainType(t)].AcceptSmudge) - map.AddSmudge(warhead.SmudgeType == SmudgeType.Crater, t.X, t.Y); - */ - } - - static int lastSmudge = 0; - static int ChooseSmudge() { return 0; /*lastSmudge = (lastSmudge + 1) % 6; return lastSmudge; */} - } -} diff --git a/OpenRA.Game/Traits/World/BibLayer.cs b/OpenRA.Game/Traits/World/BibLayer.cs index b437ea5771..3740fa9bd7 100644 --- a/OpenRA.Game/Traits/World/BibLayer.cs +++ b/OpenRA.Game/Traits/World/BibLayer.cs @@ -39,7 +39,7 @@ namespace OpenRA.Traits World world; BibLayerInfo info; - TileReference[,] tiles; + TileReference[,] tiles; Sprite[][] bibSprites; public BibLayer(Actor self, BibLayerInfo info) diff --git a/OpenRA.Game/Traits/World/SmudgeLayer.cs b/OpenRA.Game/Traits/World/SmudgeLayer.cs new file mode 100644 index 0000000000..a3d9f2797b --- /dev/null +++ b/OpenRA.Game/Traits/World/SmudgeLayer.cs @@ -0,0 +1,99 @@ +#region Copyright & License Information +/* + * Copyright 2007,2009,2010 Chris Forbes, Robert Pepperell, Matthew Bowra-Dean, Paul Chote, Alli Witheford. + * This file is part of OpenRA. + * + * OpenRA is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * OpenRA is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with OpenRA. If not, see . + */ +#endregion + +using System; +using System.Linq; +using System.Drawing; +using OpenRA.Graphics; +using OpenRA.FileFormats; +using OpenRA.GameRules; + +namespace OpenRA.Traits +{ + class SmudgeLayerInfo : ITraitInfo + { + public readonly SmudgeType Type = SmudgeType.Scorch; + public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"}; + public readonly int[] Depths = {1,1,1,1,1,1}; + public object Create(Actor self) { return new SmudgeLayer(self, this); } + } + + class SmudgeLayer: IRenderOverlay, ILoadWorldHook + { + public SmudgeLayerInfo Info; + SpriteRenderer spriteRenderer; + World world; + + TileReference[,] tiles; + Sprite[][] smudgeSprites; + string[] smudgeTypes; + + public SmudgeLayer(Actor self, SmudgeLayerInfo info) + { + spriteRenderer = new SpriteRenderer( Game.renderer, true ); + this.Info = info; + smudgeSprites = Info.Types.Select(x => SpriteSheetBuilder.LoadAllSprites(x)).ToArray(); + } + + public void WorldLoaded(World w) + { + world = w; + tiles = new TileReference[w.Map.MapSize.X,w.Map.MapSize.Y]; + + // TODO: Parse map and add initial smudges + } + + public void AddSmudge(int2 loc) + { + // No smudge; create a new one + if (tiles[loc.X, loc.Y].type == 0) + { + byte st = (byte)(1 + world.SharedRandom.Next(Info.Types.Length - 1)); + tiles[loc.X,loc.Y] = new TileReference(st,(byte)0); + return; + } + + // Existing smudge; make it deeper + int depth = Info.Depths[tiles[loc.X, loc.Y].type-1]; + if (tiles[loc.X, loc.Y].image >= depth - 1) return; /* Smudge is at maximum depth */ + + tiles[loc.X,loc.Y].image++; + } + + public void Render() + { + var shroud = world.LocalPlayer.Shroud; + var tl = world.Map.TopLeft; + var br = world.Map.BottomRight; + + for (int x = tl.X; x < br.X; x++) + for (int y = tl.Y; y < br.Y; y++) + { + var t = new int2(x, y); + if (!shroud.IsExplored(t) || tiles[x,y].type == 0) continue; + + spriteRenderer.DrawSprite(smudgeSprites[tiles[x,y].type- 1][tiles[x,y].image], + Game.CellSize * (float2)t, "terrain"); + } + + spriteRenderer.Flush(); + } + } +} diff --git a/mods/cnc/system.yaml b/mods/cnc/system.yaml index 976ea9b5b1..06c7e3bab5 100644 --- a/mods/cnc/system.yaml +++ b/mods/cnc/system.yaml @@ -199,6 +199,14 @@ World: Name: Tiberium GrowthInterval: 2 SpreadInterval: 12 + SmudgeLayer@SCORCH: + Type:Scorch + Types:sc1,sc2,sc3,sc4,sc5,sc6 + Depths:1,1,1,1,1,1 + SmudgeLayer@CRATER: + Type:Crater + Types:cr1,cr2,cr3,cr4,cr5,cr6 + Depths:5,5,5,5,5,5 SpawnMapActors: SpawnDefaultUnits: EvaAlerts: diff --git a/mods/cnc/weapons.yaml b/mods/cnc/weapons.yaml index b46053fcc4..91a66a5bd7 100644 --- a/mods/cnc/weapons.yaml +++ b/mods/cnc/weapons.yaml @@ -127,6 +127,7 @@ Rockets: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 30 Flamethrower: @@ -142,6 +143,7 @@ Flamethrower: InfDeath: 4 Explosion: 3 ImpactSound: flamer2 + SmudgeType: Scorch Damage: 35 BigFlamer: @@ -157,6 +159,7 @@ BigFlamer: InfDeath: 4 Explosion: 3 ImpactSound: flamer2 + SmudgeType: Scorch Damage: 50 Chemspray: @@ -173,6 +176,7 @@ Chemspray: Verses: 90%,75%,60%,25%,100% InfDeath: 2 Explosion: 5 + SmudgeType: Scorch ImpactSound: xplos Grenade: @@ -192,6 +196,7 @@ Grenade: InfDeath: 2 Explosion: 5 ImpactSound: xplos + SmudgeType: Crater Damage: 50 70mm: @@ -209,6 +214,7 @@ Grenade: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 25 105mm: @@ -226,6 +232,7 @@ Grenade: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 30 120mm: @@ -243,6 +250,7 @@ Grenade: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 40 TurretGun: @@ -260,6 +268,7 @@ TurretGun: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 40 MissilePack: @@ -285,6 +294,7 @@ MissilePack: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 75 227mm: @@ -310,6 +320,7 @@ MissilePack: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 75 Ballistic: @@ -330,6 +341,7 @@ Ballistic: Verses: 90%,75%,60%,25%,100% InfDeath: 2 Explosion: 5 + SmudgeType: Crater ImpactSound: xplos MachineGun: @@ -367,6 +379,7 @@ BoatMissile: InfDeath: 2 Explosion: 5 ImpactSound: xplos + SmudgeType: Crater Damage: 60 Tomahawk: @@ -391,6 +404,7 @@ Tomahawk: InfDeath: 2 Explosion: 5 ImpactSound: xplos + SmudgeType: Crater Damage: 60 Napalm: @@ -409,6 +423,7 @@ Napalm: InfDeath: 4 Explosion: 3 ImpactSound: flamer2 + SmudgeType: Scorch Damage: 100 Laser: @@ -423,6 +438,7 @@ Laser: Spread: 1 Verses: 100%,100%,100%,100%,100% InfDeath: 4 + SmudgeType: Scorch Damage: 200 Nike: @@ -446,6 +462,7 @@ Nike: InfDeath: 3 Explosion: 4 ImpactSound: xplos + SmudgeType: Crater Damage: 50 HonestJohn: @@ -467,4 +484,5 @@ HonestJohn: InfDeath: 4 Explosion: 3 ImpactSound: flamer2 + SmudgeType: Scorch Damage: 100 diff --git a/mods/ra/system.yaml b/mods/ra/system.yaml index 929b49d34b..28337a44c6 100644 --- a/mods/ra/system.yaml +++ b/mods/ra/system.yaml @@ -249,6 +249,14 @@ World: Templates:templates.ini Tileset:tileSet.til MapColors:temperat.col + SmudgeLayer@SCORCH: + Type:Scorch + Types:sc1,sc2,sc3,sc4,sc5,sc6 + Depths:1,1,1,1,1,1 + SmudgeLayer@CRATER: + Type:Crater + Types:cr1,cr2,cr3,cr4,cr5,cr6 + Depths:5,5,5,5,5,5 SpawnMapActors: SpawnDefaultUnits: EvaAlerts: