diff --git a/OpenRA.FileFormats/ShroudPaletteRemap.cs b/OpenRA.FileFormats/ShroudPaletteRemap.cs index 6f02ef5532..bd7f7a9fdd 100644 --- a/OpenRA.FileFormats/ShroudPaletteRemap.cs +++ b/OpenRA.FileFormats/ShroudPaletteRemap.cs @@ -24,6 +24,9 @@ namespace OpenRA.FileFormats { public class ShroudPaletteRemap : IPaletteRemap { + bool isFog; + + public ShroudPaletteRemap(bool isFog) { this.isFog = isFog; } public Color GetRemappedColor(Color original, int index) { // false-color version for debug @@ -36,13 +39,22 @@ namespace OpenRA.FileFormats // Color.Purple, // Color.Cyan}[index % 8]; - return 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)}[index % 8]; + if (isFog) + return new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.Transparent, + Color.Transparent, + Color.FromArgb(128,0,0,0), + Color.FromArgb(64,0,0,0)}[index % 8]; + else + return new[] { + Color.Transparent, Color.Green, + Color.Blue, Color.Yellow, + Color.Black, + Color.FromArgb(128,0,0,0), + Color.Transparent, + Color.Transparent}[index % 8]; } } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 04a14a7862..4f5f636ab0 100755 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -76,6 +76,7 @@ + diff --git a/OpenRA.Game/Shroud.cs b/OpenRA.Game/Shroud.cs index e7bc837f48..ba79178831 100644 --- a/OpenRA.Game/Shroud.cs +++ b/OpenRA.Game/Shroud.cs @@ -24,8 +24,8 @@ using System.Linq; using OpenRA.FileFormats; using OpenRA.GameRules; using OpenRA.Graphics; -using OpenRA.Traits; using OpenRA.Support; +using OpenRA.Traits; namespace OpenRA { @@ -64,6 +64,8 @@ namespace OpenRA public void Tick( World world ) { + if (owner != owner.World.LocalPlayer) return; + if (gapTicks > 0) { --gapTicks; return; } // Clear active flags @@ -102,6 +104,8 @@ namespace OpenRA public void ResetExplored() { + if (owner != owner.World.LocalPlayer) return; + explored = new bool[map.MapSize, map.MapSize]; dirty = true; } @@ -113,6 +117,8 @@ namespace OpenRA public void Explore(World w, int2 center, int range) { + if (owner != owner.World.LocalPlayer) return; + using (new PerfSample("explore")) { if (range == 0) @@ -133,6 +139,8 @@ namespace OpenRA public void Explore(Actor a) { + if (owner != owner.World.LocalPlayer) return; + var sight = a.Info.Traits.Get().Sight; // Buildings: explore from each cell in the footprint diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs new file mode 100644 index 0000000000..e15ab3908a --- /dev/null +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -0,0 +1,54 @@ +#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 System.Collections.Generic; + +namespace OpenRA.Traits +{ + class ShroudInfo : ITraitInfo + { + public object Create(Actor self) { return new Shroud(self, this); } + } + + class Shroud + { + Map map; + int[,] visibleCells; + + public Shroud(Actor self, ShroudInfo info) + { + map = self.World.Map; + visibleCells = new int[map.MapSize, map.MapSize]; + + self.World.ActorAdded += AddActor; + self.World.ActorRemoved += RemoveActor; + } + + class ActorVisibility + { + int range; + int2[] vis; + } + + void AddActor(Actor a) { } + void RemoveActor(Actor a) { } + } +} diff --git a/OpenRA.Game/Traits/World/ShroudPalette.cs b/OpenRA.Game/Traits/World/ShroudPalette.cs index 4c67e07025..47d7858341 100644 --- a/OpenRA.Game/Traits/World/ShroudPalette.cs +++ b/OpenRA.Game/Traits/World/ShroudPalette.cs @@ -24,18 +24,19 @@ namespace OpenRA.Traits { class ShroudPaletteInfo : ITraitInfo { - public object Create(Actor self) { return new ShroudPalette(self); } + public readonly string Name = "shroud"; + public readonly bool IsFog = false; + public object Create(Actor self) { return new ShroudPalette(self, this); } } class ShroudPalette { - public ShroudPalette(Actor self) + public ShroudPalette(Actor self, ShroudPaletteInfo info) { // TODO: This shouldn't rely on a base palette var wr = self.World.WorldRenderer; var pal = wr.GetPalette("terrain"); - - wr.AddPalette("shroud", new Palette(pal, new ShroudPaletteRemap())); + wr.AddPalette(info.Name, new Palette(pal, new ShroudPaletteRemap(info.IsFog))); } } }