diff --git a/OpenRA.Game/Graphics/ShroudRenderer.cs b/OpenRA.Game/Graphics/ShroudRenderer.cs index af21f5cb69..7abb76ffae 100644 --- a/OpenRA.Game/Graphics/ShroudRenderer.cs +++ b/OpenRA.Game/Graphics/ShroudRenderer.cs @@ -16,6 +16,7 @@ namespace OpenRA.Graphics public class ShroudRenderer { Map map; + ShroudInfo shroudInfo; Sprite[] shadowBits = Game.modData.SpriteLoader.LoadAllSprites("shadow"); Sprite[,] sprites, fogSprites; int shroudHash; @@ -46,6 +47,7 @@ namespace OpenRA.Graphics public ShroudRenderer(World world) { this.map = world.Map; + shroudInfo = Rules.Info["player"].Traits.Get(); sprites = new Sprite[map.MapSize.X, map.MapSize.Y]; fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y]; @@ -150,7 +152,8 @@ namespace OpenRA.Graphics { if (initializePalettes) { - fogPalette = wr.Palette("fog"); + if (shroudInfo.Fog) + fogPalette = wr.Palette("fog"); shroudPalette = wr.Palette("shroud"); initializePalettes = false; } @@ -158,8 +161,11 @@ namespace OpenRA.Graphics GenerateSprites(shroud); var clipRect = Game.viewport.WorldBounds(wr.world); + + // We draw the shroud when disabled to hide the sharp map edges DrawShroud(wr, clipRect, sprites, shroudPalette); - if (wr.world.WorldActor.HasTrait()) + + if (shroudInfo.Fog) DrawShroud(wr, clipRect, fogSprites, fogPalette); } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 3f30d687e7..670708792d 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -182,7 +182,6 @@ - diff --git a/OpenRA.Game/Traits/World/Fog.cs b/OpenRA.Game/Traits/World/Fog.cs deleted file mode 100644 index 3fae8b6bcf..0000000000 --- a/OpenRA.Game/Traits/World/Fog.cs +++ /dev/null @@ -1,20 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using OpenRA.FileFormats; - -namespace OpenRA.Traits -{ - [Desc("This tag trait will enable fog of war in ShroudRenderer.", - "Don't forget about HiddenUnderFog and FrozenUnderFog.")] - public class FogInfo : TraitInfo { } - - public class Fog { } -} \ No newline at end of file diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 2a98e97e19..bc7cf629fa 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -18,13 +18,16 @@ namespace OpenRA.Traits { public class ShroudInfo : ITraitInfo { - public object Create(ActorInitializer init) { return new Shroud(init.self); } + public readonly bool Shroud = true; + public readonly bool Fog = true; + public object Create(ActorInitializer init) { return new Shroud(init.self, this); } } public class Shroud { - Map map; + public ShroudInfo Info; Actor self; + Map map; int[,] visibleCells; bool[,] exploredCells; @@ -34,8 +37,9 @@ namespace OpenRA.Traits public int Hash { get; private set; } - public Shroud(Actor self) + public Shroud(Actor self, ShroudInfo info) { + Info = info; this.self = self; map = self.World.Map; @@ -44,6 +48,9 @@ namespace OpenRA.Traits foggedCells = new bool[map.MapSize.X, map.MapSize.Y]; self.World.ActorAdded += AddActor; self.World.ActorRemoved += RemoveActor; + + if (!info.Shroud) + ExploredBounds = map.Bounds; } void Invalidate() @@ -270,6 +277,9 @@ namespace OpenRA.Traits if (!map.IsInMap(x, y)) return false; + if (!Info.Shroud) + return true; + return foggedCells[x,y]; } @@ -286,6 +296,9 @@ namespace OpenRA.Traits if (x < 0 || x >= map.MapSize.X || y < 0 || y >= map.MapSize.Y) return false; + if (!Info.Fog) + return true; + return visibleCells[x,y] != 0; } diff --git a/OpenRA.Mods.RA/FogPalette.cs b/OpenRA.Mods.RA/FogPalette.cs deleted file mode 100644 index 92ee39cee6..0000000000 --- a/OpenRA.Mods.RA/FogPalette.cs +++ /dev/null @@ -1,46 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2013 The OpenRA Developers (see AUTHORS) - * This file is part of OpenRA, which is free software. It is made - * available to you under the terms of the GNU General Public License - * as published by the Free Software Foundation. For more information, - * see COPYING. - */ -#endregion - -using System.Drawing; -using OpenRA.FileFormats; -using OpenRA.Graphics; -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - [Desc("Adds the hard-coded fog palette to the game")] - class FogPaletteInfo : ITraitInfo - { - [Desc("internal palette name")] - public readonly string Name = "fog"; - public object Create(ActorInitializer init) { return new FogPalette(this); } - } - - class FogPalette : IPalette - { - readonly FogPaletteInfo info; - - public FogPalette(FogPaletteInfo info) { this.info = info; } - - public void InitPalette(WorldRenderer wr) - { - var c = new[] { - Color.Transparent, Color.Green, - Color.Blue, Color.Yellow, - Color.FromArgb(128,0,0,0), - Color.FromArgb(128,0,0,0), - Color.FromArgb(128,0,0,0), - Color.FromArgb(64,0,0,0) - }; - - wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false); - } - } -} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 6909ff4a35..f794438910 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -416,7 +416,6 @@ - diff --git a/OpenRA.Mods.RA/ShroudPalette.cs b/OpenRA.Mods.RA/ShroudPalette.cs index 3fed81a6eb..247a87986e 100644 --- a/OpenRA.Mods.RA/ShroudPalette.cs +++ b/OpenRA.Mods.RA/ShroudPalette.cs @@ -15,11 +15,17 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { + public enum ShroudPaletteType { Shroud, Fog, Combined }; + [Desc("Adds the hard-coded shroud palette to the game")] class ShroudPaletteInfo : ITraitInfo { - [Desc("internal palette name")] + [Desc("Internal palette name")] public readonly string Name = "shroud"; + + [Desc("Palette type")] + public readonly ShroudPaletteType Type = ShroudPaletteType.Combined; + public object Create(ActorInitializer init) { return new ShroudPalette(this); } } @@ -31,16 +37,37 @@ namespace OpenRA.Mods.RA public void InitPalette(WorldRenderer wr) { - var c = new[] { - Color.Transparent, Color.Green, - Color.Blue, Color.Yellow, - Color.Black, - Color.FromArgb(128,0,0,0), - Color.Transparent, - Color.Transparent - }; + var c = info.Type == ShroudPaletteType.Shroud ? Shroud : + info.Type == ShroudPaletteType.Fog ? Fog : Combined; wr.AddPalette(info.Name, new Palette(Exts.MakeArray(256, i => (uint)c[i % 8].ToArgb())), false); } + + static Color[] Shroud = new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.Black, + Color.FromArgb(128,0,0,0), + Color.Transparent, + Color.Transparent + }; + + static Color[] Fog = new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.FromArgb(128,0,0,0), + Color.FromArgb(128,0,0,0), + Color.FromArgb(128,0,0,0), + Color.FromArgb(64,0,0,0) + }; + + static Color[] Combined = new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.Black, + Color.FromArgb(192,0,0,0), + Color.FromArgb(128,0,0,0), + Color.FromArgb(64,0,0,0) + }; } } diff --git a/mods/cnc-classic/rules/system.yaml b/mods/cnc-classic/rules/system.yaml index 3e88c7bcd6..58e6ffcf31 100644 --- a/mods/cnc-classic/rules/system.yaml +++ b/mods/cnc-classic/rules/system.yaml @@ -95,6 +95,7 @@ Player: DebugResourceOre: DebugResourceOreCapacity: Shroud: + Fog: false BaseAttackNotifier: PlayerStatistics: @@ -159,7 +160,6 @@ World: B: 0 A: 180 ShroudPalette: - FogPalette: Country@gdi: Name: GDI Race: gdi diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index 2f84a6608e..c327250b94 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -257,8 +257,11 @@ World: G: 0 B: 0 A: 180 - ShroudPalette: - FogPalette: + ShroudPalette@shroud: + Type: Shroud + ShroudPalette@fog: + Name: fog + Type: Fog Country@gdi: Name: GDI Race: gdi @@ -306,7 +309,6 @@ World: MPStartLocations: SpatialBins: BinSize: 4 - Fog: CrateSpawner: Minimum: 1 Maximum: 6 diff --git a/mods/d2k/rules/system.yaml b/mods/d2k/rules/system.yaml index d79a233cbf..e223d9b035 100644 --- a/mods/d2k/rules/system.yaml +++ b/mods/d2k/rules/system.yaml @@ -340,8 +340,11 @@ World: G: 0 B: 0 A: 180 - ShroudPalette: - FogPalette: + ShroudPalette@shroud: + Type: Shroud + ShroudPalette@fog: + Name: fog + Type: Fog Country@Atreides: Name: Atreides Race: atreides @@ -388,7 +391,6 @@ World: Faction: ordos SpatialBins: BinSize: 4 - Fog: PathFinder: ValidateOrder: DebugPauseState: diff --git a/mods/ra-classic/rules/system.yaml b/mods/ra-classic/rules/system.yaml index c3775aafc4..60f22de31f 100644 --- a/mods/ra-classic/rules/system.yaml +++ b/mods/ra-classic/rules/system.yaml @@ -122,6 +122,7 @@ Player: DebugResourceOreCapacity: GpsWatcher: Shroud: + Fog: false BaseAttackNotifier: PlayerStatistics: @@ -193,7 +194,6 @@ World: B: 0 A: 180 ShroudPalette: - FogPalette: Country@0: Name: Allies Race: allies diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index 5553568e19..3d946f1952 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -574,8 +574,11 @@ World: G: 0 B: 0 A: 180 - ShroudPalette: - FogPalette: + ShroudPalette@shroud: + Type: Shroud + ShroudPalette@fog: + Name: fog + Type: Fog Country@0: Name: Allies Race: allies @@ -621,7 +624,6 @@ World: SpawnMPUnits: SpatialBins: BinSize: 4 - Fog: PathFinder: ValidateOrder: DebugPauseState: