Fix GPS/Disabled shroud

This commit is contained in:
Paul Chote
2010-04-09 19:59:16 +12:00
parent 5c978df9a4
commit 36a6123dd2
5 changed files with 24 additions and 13 deletions

View File

@@ -151,7 +151,7 @@ namespace OpenRA
public static void LoadMap(string mapName)
{
Timer.Time( "----LoadMap" );
SheetBuilder.Initialize(renderer);
var manifest = new Manifest(LobbyInfo.GlobalSettings.Mods);
Timer.Time( "manifest: {0}" );

View File

@@ -17,7 +17,7 @@
* along with OpenRA. If not, see <http://www.gnu.org/licenses/>.
*/
#endregion
using System;
using System.Drawing;
using OpenRA.FileFormats;
using OpenRA.FileFormats.Graphics;
@@ -47,6 +47,8 @@ namespace OpenRA.Graphics
Vertex[] vertices = new Vertex[4 * map.Height * map.Width];
ushort[] indices = new ushort[6 * map.Height * map.Width];
terrainSheet = tileMapping[map.MapTiles[map.TopLeft.X, map.TopLeft.Y]].sheet;
int nv = 0;
int ni = 0;
for( int j = map.TopLeft.Y ; j < map.BottomRight.Y; j++ )
@@ -58,9 +60,10 @@ namespace OpenRA.Graphics
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
nv += 4;
ni += 6;
}
terrainSheet = tileMapping[map.MapTiles[map.TopLeft.X, map.TopLeft.Y]].sheet;
if (tileMapping[map.MapTiles[i, j]].sheet != terrainSheet)
throw new InvalidOperationException("Terrain sprites span multiple sheets");
}
vertexBuffer = renderer.Device.CreateVertexBuffer( vertices.Length );
vertexBuffer.SetData( vertices );
@@ -85,7 +88,7 @@ namespace OpenRA.Graphics
if (firstRow < 0) firstRow = 0;
if (lastRow > map.Height) lastRow = map.Height;
if (!Game.world.LocalPlayer.Shroud.HasGPS && Game.world.LocalPlayer.Shroud.bounds.HasValue)
if (!Game.world.LocalPlayer.Shroud.Disabled && Game.world.LocalPlayer.Shroud.bounds.HasValue)
{
var r = Game.world.LocalPlayer.Shroud.bounds.Value;
if (firstRow < r.Top - map.YOffset)

View File

@@ -84,7 +84,7 @@ namespace OpenRA.Graphics
Rectangle GetBoundsRect()
{
if (!world.LocalPlayer.Shroud.HasGPS && world.LocalPlayer.Shroud.bounds.HasValue)
if (!world.LocalPlayer.Shroud.Disabled && world.LocalPlayer.Shroud.bounds.HasValue)
{
var r = world.LocalPlayer.Shroud.bounds.Value;

View File

@@ -32,7 +32,7 @@ namespace OpenRA
Sprite[,] sprites, fogSprites;
bool dirty = true;
bool hasGPS = false;
bool disabled = false;
Player owner;
Map map;
@@ -50,14 +50,19 @@ namespace OpenRA
shroud.Dirty += () => dirty = true;
}
public bool HasGPS
public bool Disabled
{
get { return hasGPS; }
set { hasGPS = value; dirty = true;}
get { return disabled; }
set { disabled = value; dirty = true;}
}
public bool IsExplored(int2 xy) { return IsExplored(xy.X, xy.Y); }
bool IsExplored(int x, int y) { return shroud.exploredCells[x,y]; }
bool IsExplored(int x, int y)
{
if (disabled)
return true;
return shroud.exploredCells[x,y];
}
public bool DisplayOnRadar(int x, int y) { return IsExplored(x, y); }
@@ -132,6 +137,9 @@ namespace OpenRA
internal void Draw(SpriteRenderer r)
{
if (disabled)
return;
if (dirty)
{
dirty = false;

View File

@@ -1,4 +1,4 @@
#region Copyright & License Information
#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.
@@ -50,7 +50,7 @@ namespace OpenRA.Mods.RA
w.Add(new SatelliteLaunch(launchSite));
w.Add(new DelayedAction((Info as GpsPowerInfo).RevealDelay * 25,
() => Owner.Shroud.HasGPS = true));
() => Owner.Shroud.Disabled = true));
});
FinishActivate();