Add lobby options for Shroud and Fog.

This commit is contained in:
Paul Chote
2013-08-04 12:25:32 +12:00
parent d867e8200f
commit c08f602661
14 changed files with 143 additions and 47 deletions

View File

@@ -15,8 +15,8 @@ namespace OpenRA.Graphics
{
public class ShroudRenderer
{
World world;
Map map;
ShroudInfo shroudInfo;
Sprite[] shadowBits = Game.modData.SpriteLoader.LoadAllSprites("shadow");
Sprite[,] sprites, fogSprites;
int shroudHash;
@@ -46,8 +46,8 @@ namespace OpenRA.Graphics
public ShroudRenderer(World world)
{
this.world = world;
this.map = world.Map;
shroudInfo = Rules.Info["player"].Traits.Get<ShroudInfo>();
sprites = new Sprite[map.MapSize.X, map.MapSize.Y];
fogSprites = new Sprite[map.MapSize.X, map.MapSize.Y];
@@ -152,9 +152,10 @@ namespace OpenRA.Graphics
{
if (initializePalettes)
{
if (shroudInfo.Fog)
if (world.LobbyInfo.GlobalSettings.Fog)
fogPalette = wr.Palette("fog");
shroudPalette = wr.Palette("shroud");
shroudPalette = world.LobbyInfo.GlobalSettings.Fog ? wr.Palette("shroud") : wr.Palette("shroudfog");
initializePalettes = false;
}
@@ -165,7 +166,7 @@ namespace OpenRA.Graphics
// We draw the shroud when disabled to hide the sharp map edges
DrawShroud(wr, clipRect, sprites, shroudPalette);
if (shroudInfo.Fog)
if (world.LobbyInfo.GlobalSettings.Fog)
DrawShroud(wr, clipRect, fogSprites, fogPalette);
}

View File

@@ -92,6 +92,8 @@ namespace OpenRA.Network
public bool Dedicated;
public string Difficulty;
public bool Crates = true;
public bool Shroud = true;
public bool Fog = true;
public string StartingUnitsClass = "default";
public bool AllowVersionMismatch;
}

View File

@@ -18,14 +18,11 @@ namespace OpenRA.Traits
{
public class ShroudInfo : ITraitInfo
{
public readonly bool Shroud = true;
public readonly bool Fog = true;
public object Create(ActorInitializer init) { return new Shroud(init.self, this); }
public object Create(ActorInitializer init) { return new Shroud(init.self); }
}
public class Shroud
{
public ShroudInfo Info;
Actor self;
Map map;
@@ -42,9 +39,8 @@ namespace OpenRA.Traits
public int Hash { get; private set; }
public Shroud(Actor self, ShroudInfo info)
public Shroud(Actor self)
{
Info = info;
this.self = self;
map = self.World.Map;
@@ -58,7 +54,7 @@ namespace OpenRA.Traits
self.World.ActorAdded += AddShroudGeneration;
self.World.ActorRemoved += RemoveShroudGeneration;
if (!info.Shroud)
if (!self.World.LobbyInfo.GlobalSettings.Shroud)
ExploredBounds = map.Bounds;
}
@@ -252,7 +248,7 @@ namespace OpenRA.Traits
if (!map.IsInMap(x, y))
return false;
if (!Info.Shroud)
if (!self.World.LobbyInfo.GlobalSettings.Shroud)
return true;
return explored[x, y] && (generatedShroudCount[x, y] == 0 || visibleCount[x, y] > 0);
@@ -271,7 +267,7 @@ namespace OpenRA.Traits
if (x < 0 || x >= map.MapSize.X || y < 0 || y >= map.MapSize.Y)
return false;
if (!Info.Fog)
if (!self.World.LobbyInfo.GlobalSettings.Fog)
return true;
return visibleCount[x, y] > 0;