moving Map, TileSet from Rules to World
This commit is contained in:
@@ -85,7 +85,7 @@ namespace OpenRa
|
|||||||
if (Owner != Game.LocalPlayer)
|
if (Owner != Game.LocalPlayer)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (!Rules.Map.IsInMap(xy.X, xy.Y))
|
if (!Game.world.Map.IsInMap(xy.X, xy.Y))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var loc = mi.Location + Game.viewport.Location;
|
var loc = mi.Location + Game.viewport.Location;
|
||||||
|
|||||||
@@ -64,7 +64,6 @@ namespace OpenRa
|
|||||||
SpriteSheetBuilder.Initialize();
|
SpriteSheetBuilder.Initialize();
|
||||||
FileSystem.UnmountTemporaryPackages();
|
FileSystem.UnmountTemporaryPackages();
|
||||||
Rules.LoadRules(mapName, usingAftermath);
|
Rules.LoadRules(mapName, usingAftermath);
|
||||||
palette = new HardwarePalette(renderer, Rules.Map);
|
|
||||||
|
|
||||||
world = new World();
|
world = new World();
|
||||||
Game.world.ActorAdded += a =>
|
Game.world.ActorAdded += a =>
|
||||||
@@ -73,6 +72,8 @@ namespace OpenRa
|
|||||||
a.Owner.Shroud.Explore(a);
|
a.Owner.Shroud.Explore(a);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
palette = new HardwarePalette(renderer, world.Map);
|
||||||
|
|
||||||
var worldActor = new Actor("World", new int2(int.MaxValue, int.MaxValue), null);
|
var worldActor = new Actor("World", new int2(int.MaxValue, int.MaxValue), null);
|
||||||
Game.world.Add(worldActor);
|
Game.world.Add(worldActor);
|
||||||
|
|
||||||
@@ -83,11 +84,11 @@ namespace OpenRa
|
|||||||
players[i] = new Player(i, LobbyInfo.Clients.FirstOrDefault(a => a.Index == i));
|
players[i] = new Player(i, LobbyInfo.Clients.FirstOrDefault(a => a.Index == i));
|
||||||
}
|
}
|
||||||
|
|
||||||
Rules.Map.InitOreDensity();
|
Game.world.Map.InitOreDensity();
|
||||||
worldRenderer = new WorldRenderer(renderer);
|
worldRenderer = new WorldRenderer(renderer);
|
||||||
|
|
||||||
SequenceProvider.Initialize(usingAftermath);
|
SequenceProvider.Initialize(usingAftermath);
|
||||||
viewport = new Viewport(clientSize, Rules.Map.Offset, Rules.Map.Offset + Rules.Map.Size, renderer);
|
viewport = new Viewport(clientSize, Game.world.Map.Offset, Game.world.Map.Offset + Game.world.Map.Size, renderer);
|
||||||
|
|
||||||
minimap = new Minimap(renderer);
|
minimap = new Minimap(renderer);
|
||||||
|
|
||||||
@@ -95,7 +96,7 @@ namespace OpenRa
|
|||||||
UnitInfluence = new UnitInfluenceMap();
|
UnitInfluence = new UnitInfluenceMap();
|
||||||
|
|
||||||
skipMakeAnims = true;
|
skipMakeAnims = true;
|
||||||
foreach (var treeReference in Rules.Map.Trees)
|
foreach (var treeReference in Game.world.Map.Trees)
|
||||||
world.Add(new Actor(treeReference.Image, new int2(treeReference.Location), null));
|
world.Add(new Actor(treeReference.Image, new int2(treeReference.Location), null));
|
||||||
|
|
||||||
LoadMapActors(Rules.AllRules);
|
LoadMapActors(Rules.AllRules);
|
||||||
@@ -202,7 +203,7 @@ namespace OpenRa
|
|||||||
if (--oreTicks == 0)
|
if (--oreTicks == 0)
|
||||||
using (new PerfSample("ore"))
|
using (new PerfSample("ore"))
|
||||||
{
|
{
|
||||||
Rules.Map.GrowOre(SharedRandom);
|
Game.world.Map.GrowOre(SharedRandom);
|
||||||
minimap.InvalidateOre();
|
minimap.InvalidateOre();
|
||||||
oreTicks = oreFrequency;
|
oreTicks = oreFrequency;
|
||||||
}
|
}
|
||||||
@@ -250,9 +251,9 @@ namespace OpenRa
|
|||||||
if (BuildingInfluence.GetBuildingAt(a) != null) return false;
|
if (BuildingInfluence.GetBuildingAt(a) != null) return false;
|
||||||
if (UnitInfluence.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
if (UnitInfluence.GetUnitsAt(a).Any(b => b != toIgnore)) return false;
|
||||||
|
|
||||||
return Rules.Map.IsInMap(a.X, a.Y) &&
|
return Game.world.Map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(umt,
|
TerrainCosts.Cost(umt,
|
||||||
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool IsActorCrushableByActor(Actor a, Actor b)
|
public static bool IsActorCrushableByActor(Actor a, Actor b)
|
||||||
@@ -276,9 +277,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static bool IsWater(int2 a)
|
public static bool IsWater(int2 a)
|
||||||
{
|
{
|
||||||
return Rules.Map.IsInMap(a.X, a.Y) &&
|
return Game.world.Map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(UnitMovementType.Float,
|
TerrainCosts.Cost(UnitMovementType.Float,
|
||||||
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerable<Actor> FindUnits(float2 a, float2 b)
|
public static IEnumerable<Actor> FindUnits(float2 a, float2 b)
|
||||||
@@ -336,7 +337,7 @@ namespace OpenRa
|
|||||||
public static bool CanPlaceBuilding(string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
public static bool CanPlaceBuilding(string name, BuildingInfo building, int2 xy, Actor toIgnore, bool adjust)
|
||||||
{
|
{
|
||||||
return !Footprint.Tiles(name, building, xy, adjust).Any(
|
return !Footprint.Tiles(name, building, xy, adjust).Any(
|
||||||
t => !Rules.Map.IsInMap(t.X, t.Y) || Rules.Map.ContainsResource(t) || !Game.IsCellBuildable(t,
|
t => !Game.world.Map.IsInMap(t.X, t.Y) || Game.world.Map.ContainsResource(t) || !Game.IsCellBuildable(t,
|
||||||
building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
|
building.WaterBound ? UnitMovementType.Float : UnitMovementType.Wheel,
|
||||||
toIgnore));
|
toIgnore));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ namespace OpenRa
|
|||||||
public static GeneralInfo General;
|
public static GeneralInfo General;
|
||||||
public static AftermathInfo Aftermath;
|
public static AftermathInfo Aftermath;
|
||||||
public static TechTree TechTree;
|
public static TechTree TechTree;
|
||||||
public static Map Map;
|
|
||||||
public static TileSet TileSet;
|
|
||||||
|
|
||||||
public static Dictionary<string, ActorInfo> ActorInfo;
|
public static Dictionary<string, ActorInfo> ActorInfo;
|
||||||
|
|
||||||
@@ -75,9 +73,6 @@ namespace OpenRa
|
|||||||
ActorInfo.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
ActorInfo.Add(kv.Key.ToLowerInvariant(), new ActorInfo(kv.Key.ToLowerInvariant(), kv.Value, yamlRules));
|
||||||
|
|
||||||
TechTree = new TechTree();
|
TechTree = new TechTree();
|
||||||
Map = new Map( AllRules );
|
|
||||||
FileSystem.MountTemporary( new Package( Rules.Map.Theater + ".mix" ) );
|
|
||||||
TileSet = new TileSet( Map.TileSuffix );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LoadCategories(params string[] types)
|
static void LoadCategories(params string[] types)
|
||||||
|
|||||||
@@ -23,12 +23,12 @@ namespace OpenRa.Graphics
|
|||||||
mapOnlySheet = new Sheet(r, new Size(128, 128));
|
mapOnlySheet = new Sheet(r, new Size(128, 128));
|
||||||
|
|
||||||
rgbaRenderer = new SpriteRenderer(r, true, r.RgbaSpriteShader);
|
rgbaRenderer = new SpriteRenderer(r, true, r.RgbaSpriteShader);
|
||||||
var size = Math.Max(Rules.Map.Width, Rules.Map.Height);
|
var size = Math.Max(Game.world.Map.Width, Game.world.Map.Height);
|
||||||
var dw = (size - Rules.Map.Width) / 2;
|
var dw = (size - Game.world.Map.Width) / 2;
|
||||||
var dh = (size - Rules.Map.Height) / 2;
|
var dh = (size - Game.world.Map.Height) / 2;
|
||||||
|
|
||||||
sprite = new Sprite(sheet, new Rectangle(Rules.Map.Offset.X+dw, Rules.Map.Offset.Y+dh, size, size), TextureChannel.Alpha);
|
sprite = new Sprite(sheet, new Rectangle(Game.world.Map.Offset.X+dw, Game.world.Map.Offset.Y+dh, size, size), TextureChannel.Alpha);
|
||||||
mapOnlySprite = new Sprite(mapOnlySheet, new Rectangle(Rules.Map.Offset.X + dw, Rules.Map.Offset.Y + dh, size, size), TextureChannel.Alpha);
|
mapOnlySprite = new Sprite(mapOnlySheet, new Rectangle(Game.world.Map.Offset.X + dw, Game.world.Map.Offset.Y + dh, size, size), TextureChannel.Alpha);
|
||||||
}
|
}
|
||||||
|
|
||||||
Color[] terrainTypeColors;
|
Color[] terrainTypeColors;
|
||||||
@@ -40,15 +40,15 @@ namespace OpenRa.Graphics
|
|||||||
|
|
||||||
public void Update()
|
public void Update()
|
||||||
{
|
{
|
||||||
if (Rules.Map.Theater != theater)
|
if (Game.world.Map.Theater != theater)
|
||||||
{
|
{
|
||||||
terrainTypeColors = null;
|
terrainTypeColors = null;
|
||||||
theater = Rules.Map.Theater;
|
theater = Game.world.Map.Theater;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (terrainTypeColors == null)
|
if (terrainTypeColors == null)
|
||||||
{
|
{
|
||||||
var pal = new Palette(FileSystem.Open(Rules.Map.Theater + ".pal"));
|
var pal = new Palette(FileSystem.Open(Game.world.Map.Theater + ".pal"));
|
||||||
terrainTypeColors = new[] {
|
terrainTypeColors = new[] {
|
||||||
Color.FromArgb(alpha, pal.GetColor(theater.ToLowerInvariant() == "snow" ? 0xe3 :0x1a)),
|
Color.FromArgb(alpha, pal.GetColor(theater.ToLowerInvariant() == "snow" ? 0xe3 :0x1a)),
|
||||||
Color.FromArgb(alpha, pal.GetColor(0x63)),
|
Color.FromArgb(alpha, pal.GetColor(0x63)),
|
||||||
@@ -71,8 +71,8 @@ namespace OpenRa.Graphics
|
|||||||
terrain = new Bitmap(128, 128);
|
terrain = new Bitmap(128, 128);
|
||||||
for (var y = 0; y < 128; y++)
|
for (var y = 0; y < 128; y++)
|
||||||
for (var x = 0; x < 128; x++)
|
for (var x = 0; x < 128; x++)
|
||||||
terrain.SetPixel(x, y, Rules.Map.IsInMap(x, y)
|
terrain.SetPixel(x, y, Game.world.Map.IsInMap(x, y)
|
||||||
? terrainTypeColors[Rules.TileSet.GetWalkability(Rules.Map.MapTiles[x, y])]
|
? terrainTypeColors[Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[x, y])]
|
||||||
: shroudColor);
|
: shroudColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRa.Graphics
|
|||||||
oreLayer = new Bitmap(terrain);
|
oreLayer = new Bitmap(terrain);
|
||||||
for (var y = 0; y < 128; y++)
|
for (var y = 0; y < 128; y++)
|
||||||
for (var x = 0; x < 128; x++)
|
for (var x = 0; x < 128; x++)
|
||||||
if (Rules.Map.ContainsResource(new int2(x, y)))
|
if (Game.world.Map.ContainsResource(new int2(x, y)))
|
||||||
oreLayer.SetPixel(x, y, terrainTypeColors[(int)TerrainMovementType.Ore]);
|
oreLayer.SetPixel(x, y, terrainTypeColors[(int)TerrainMovementType.Ore]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,79 +1,79 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using Ijw.DirectX;
|
using Ijw.DirectX;
|
||||||
using IjwFramework.Collections;
|
using IjwFramework.Collections;
|
||||||
using OpenRa.FileFormats;
|
using OpenRa.FileFormats;
|
||||||
|
|
||||||
namespace OpenRa.Graphics
|
namespace OpenRa.Graphics
|
||||||
{
|
{
|
||||||
class TerrainRenderer
|
class TerrainRenderer
|
||||||
{
|
{
|
||||||
FvfVertexBuffer<Vertex> vertexBuffer;
|
FvfVertexBuffer<Vertex> vertexBuffer;
|
||||||
IndexBuffer indexBuffer;
|
IndexBuffer indexBuffer;
|
||||||
Sheet terrainSheet;
|
Sheet terrainSheet;
|
||||||
|
|
||||||
Renderer renderer;
|
Renderer renderer;
|
||||||
Map map;
|
Map map;
|
||||||
OverlayRenderer overlayRenderer;
|
OverlayRenderer overlayRenderer;
|
||||||
|
|
||||||
public TerrainRenderer(Renderer renderer, Map map)
|
public TerrainRenderer(Renderer renderer, Map map)
|
||||||
{
|
{
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
this.map = map;
|
this.map = map;
|
||||||
|
|
||||||
Size tileSize = new Size( Game.CellSize, Game.CellSize );
|
Size tileSize = new Size( Game.CellSize, Game.CellSize );
|
||||||
|
|
||||||
var tileMapping = new Cache<TileReference, Sprite>(
|
var tileMapping = new Cache<TileReference, Sprite>(
|
||||||
x => SheetBuilder.Add(Rules.TileSet.GetBytes(x), tileSize));
|
x => SheetBuilder.Add(Game.world.TileSet.GetBytes(x), tileSize));
|
||||||
|
|
||||||
Vertex[] vertices = new Vertex[4 * map.Height * map.Width];
|
Vertex[] vertices = new Vertex[4 * map.Height * map.Width];
|
||||||
ushort[] indices = new ushort[6 * map.Height * map.Width];
|
ushort[] indices = new ushort[6 * map.Height * map.Width];
|
||||||
|
|
||||||
int nv = 0;
|
int nv = 0;
|
||||||
int ni = 0;
|
int ni = 0;
|
||||||
for( int j = map.YOffset ; j < map.YOffset + map.Height ; j++ )
|
for( int j = map.YOffset ; j < map.YOffset + map.Height ; j++ )
|
||||||
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
for( int i = map.XOffset ; i < map.XOffset + map.Width; i++ )
|
||||||
{
|
{
|
||||||
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
Sprite tile = tileMapping[map.MapTiles[i, j]];
|
||||||
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
|
Util.FastCreateQuad(vertices, indices, Game.CellSize * new float2(i, j), tile, 0, nv, ni, tile.size);
|
||||||
nv += 4;
|
nv += 4;
|
||||||
ni += 6;
|
ni += 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
terrainSheet = tileMapping[map.MapTiles[map.XOffset, map.YOffset]].sheet;
|
terrainSheet = tileMapping[map.MapTiles[map.XOffset, map.YOffset]].sheet;
|
||||||
|
|
||||||
vertexBuffer = new FvfVertexBuffer<Vertex>( renderer.Device, vertices.Length, Vertex.Format );
|
vertexBuffer = new FvfVertexBuffer<Vertex>( renderer.Device, vertices.Length, Vertex.Format );
|
||||||
vertexBuffer.SetData( vertices );
|
vertexBuffer.SetData( vertices );
|
||||||
|
|
||||||
indexBuffer = new IndexBuffer( renderer.Device, indices.Length );
|
indexBuffer = new IndexBuffer( renderer.Device, indices.Length );
|
||||||
indexBuffer.SetData( indices );
|
indexBuffer.SetData( indices );
|
||||||
|
|
||||||
overlayRenderer = new OverlayRenderer( renderer, map );
|
overlayRenderer = new OverlayRenderer( renderer, map );
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Draw( Viewport viewport )
|
public void Draw( Viewport viewport )
|
||||||
{
|
{
|
||||||
int indicesPerRow = map.Width * 6;
|
int indicesPerRow = map.Width * 6;
|
||||||
int verticesPerRow = map.Width * 4;
|
int verticesPerRow = map.Width * 4;
|
||||||
|
|
||||||
int visibleRows = (int)(viewport.Width / 24.0f + 2);
|
int visibleRows = (int)(viewport.Width / 24.0f + 2);
|
||||||
|
|
||||||
int firstRow = (int)((viewport.Location.Y) / 24.0f - map.YOffset);
|
int firstRow = (int)((viewport.Location.Y) / 24.0f - map.YOffset);
|
||||||
int lastRow = firstRow + visibleRows;
|
int lastRow = firstRow + visibleRows;
|
||||||
|
|
||||||
if (lastRow < 0 || firstRow > map.Height)
|
if (lastRow < 0 || firstRow > map.Height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (firstRow < 0) firstRow = 0;
|
if (firstRow < 0) firstRow = 0;
|
||||||
if (lastRow > map.Height) lastRow = map.Height;
|
if (lastRow > map.Height) lastRow = map.Height;
|
||||||
|
|
||||||
renderer.SpriteShader.Quality = ShaderQuality.Low;
|
renderer.SpriteShader.Quality = ShaderQuality.Low;
|
||||||
renderer.SpriteShader.Render(() =>
|
renderer.SpriteShader.Render(() =>
|
||||||
renderer.DrawBatch(vertexBuffer, indexBuffer,
|
renderer.DrawBatch(vertexBuffer, indexBuffer,
|
||||||
new Range<int>(verticesPerRow * firstRow, verticesPerRow * lastRow),
|
new Range<int>(verticesPerRow * firstRow, verticesPerRow * lastRow),
|
||||||
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
|
new Range<int>(indicesPerRow * firstRow, indicesPerRow * lastRow),
|
||||||
terrainSheet.Texture, PrimitiveType.TriangleList, renderer.SpriteShader));
|
terrainSheet.Texture, PrimitiveType.TriangleList, renderer.SpriteShader));
|
||||||
|
|
||||||
overlayRenderer.Draw();
|
overlayRenderer.Draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ namespace OpenRa.Graphics
|
|||||||
|
|
||||||
internal WorldRenderer(Renderer renderer)
|
internal WorldRenderer(Renderer renderer)
|
||||||
{
|
{
|
||||||
terrainRenderer = new TerrainRenderer(renderer, Rules.Map);
|
terrainRenderer = new TerrainRenderer(renderer, Game.world.Map);
|
||||||
|
|
||||||
this.renderer = renderer;
|
this.renderer = renderer;
|
||||||
spriteRenderer = new SpriteRenderer(renderer, true);
|
spriteRenderer = new SpriteRenderer(renderer, true);
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static void Destroy(int i, int j)
|
public static void Destroy(int i, int j)
|
||||||
{
|
{
|
||||||
if (Rules.Map.ContainsResource(new int2(i, j)))
|
if (Game.world.Map.ContainsResource(new int2(i, j)))
|
||||||
{
|
{
|
||||||
Rules.Map.MapTiles[i, j].density = 0;
|
Game.world.Map.MapTiles[i, j].density = 0;
|
||||||
Rules.Map.MapTiles[i, j].overlay = 0xff;
|
Game.world.Map.MapTiles[i, j].overlay = 0xff;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,7 +32,7 @@ namespace OpenRa
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return TerrainCosts.Cost(UnitMovementType.Wheel,
|
return TerrainCosts.Cost(UnitMovementType.Wheel,
|
||||||
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[i, j]))
|
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[i, j]))
|
||||||
< double.PositiveInfinity;
|
< double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ namespace OpenRa
|
|||||||
for( int x = 0 ; x < 128 ; x++ )
|
for( int x = 0 ; x < 128 ; x++ )
|
||||||
for( int y = 0 ; y < 128 ; y++ )
|
for( int y = 0 ; y < 128 ; y++ )
|
||||||
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ )
|
for (var umt = UnitMovementType.Foot; umt <= UnitMovementType.Float; umt++ )
|
||||||
passableCost[(int)umt][ x, y ] = ( Rules.Map.IsInMap( x, y ) )
|
passableCost[(int)umt][ x, y ] = ( Game.world.Map.IsInMap( x, y ) )
|
||||||
? (float)TerrainCosts.Cost( umt, Rules.TileSet.GetWalkability( Rules.Map.MapTiles[ x, y ] ) )
|
? (float)TerrainCosts.Cost( umt, Game.world.TileSet.GetWalkability( Game.world.Map.MapTiles[ x, y ] ) )
|
||||||
: float.PositiveInfinity;
|
: float.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
int2 newHere = p.Location + d;
|
int2 newHere = p.Location + d;
|
||||||
|
|
||||||
if (!Rules.Map.IsInMap(newHere.X, newHere.Y)) continue;
|
if (!Game.world.Map.IsInMap(newHere.X, newHere.Y)) continue;
|
||||||
if( cellInfo[ newHere.X, newHere.Y ].Seen )
|
if( cellInfo[ newHere.X, newHere.Y ].Seen )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ namespace OpenRa
|
|||||||
if (!Game.BuildingInfluence.CanMoveHere(newHere) &&
|
if (!Game.BuildingInfluence.CanMoveHere(newHere) &&
|
||||||
Game.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
|
Game.BuildingInfluence.GetBuildingAt(newHere) != ignoreBuilding)
|
||||||
continue;
|
continue;
|
||||||
if (Rules.Map.IsOverlaySolid(newHere))
|
if (Game.world.Map.IsOverlaySolid(newHere))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +93,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
public void AddInitialCell( int2 location )
|
public void AddInitialCell( int2 location )
|
||||||
{
|
{
|
||||||
if (!Rules.Map.IsInMap(location.X, location.Y))
|
if (!Game.world.Map.IsInMap(location.X, location.Y))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
cellInfo[ location.X, location.Y ] = new CellInfo( 0, location, false );
|
cellInfo[ location.X, location.Y ] = new CellInfo( 0, location, false );
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ namespace OpenRa
|
|||||||
|
|
||||||
public static void AddSmudge(bool isCrater, int x, int y)
|
public static void AddSmudge(bool isCrater, int x, int y)
|
||||||
{
|
{
|
||||||
var smudge = Rules.Map.MapTiles[x, y].smudge;
|
var smudge = Game.world.Map.MapTiles[x, y].smudge;
|
||||||
if (smudge == 0)
|
if (smudge == 0)
|
||||||
Rules.Map.MapTiles[x, y].smudge = (byte) (isCrater
|
Game.world.Map.MapTiles[x, y].smudge = (byte) (isCrater
|
||||||
? (firstCrater + framesPerCrater * ChooseSmudge())
|
? (firstCrater + framesPerCrater * ChooseSmudge())
|
||||||
: (firstScorch + ChooseSmudge()));
|
: (firstScorch + ChooseSmudge()));
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ namespace OpenRa
|
|||||||
/* deepen the crater */
|
/* deepen the crater */
|
||||||
var amount = (smudge - firstCrater) % framesPerCrater;
|
var amount = (smudge - firstCrater) % framesPerCrater;
|
||||||
if (amount < framesPerCrater - 1)
|
if (amount < framesPerCrater - 1)
|
||||||
Rules.Map.MapTiles[x, y].smudge++;
|
Game.world.Map.MapTiles[x, y].smudge++;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void AddSmudge(int2 targetTile, WarheadInfo warhead)
|
public static void AddSmudge(int2 targetTile, WarheadInfo warhead)
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ namespace OpenRa.Traits.Activities
|
|||||||
var renderUnit = self.traits.Get<RenderUnit>(); /* better have one of these! */
|
var renderUnit = self.traits.Get<RenderUnit>(); /* better have one of these! */
|
||||||
|
|
||||||
var isGem = false;
|
var isGem = false;
|
||||||
if (!Rules.Map.ContainsResource(self.Location) ||
|
if (!Game.world.Map.ContainsResource(self.Location) ||
|
||||||
!Rules.Map.Harvest(self.Location, out isGem))
|
!Game.world.Map.Harvest(self.Location, out isGem))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var harvestAnim = "harvest" + Util.QuantizeFacing(unit.Facing, 8);
|
var harvestAnim = "harvest" + Util.QuantizeFacing(unit.Facing, 8);
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRa.Traits.Activities
|
|||||||
{
|
{
|
||||||
var search = new PathSearch
|
var search = new PathSearch
|
||||||
{
|
{
|
||||||
heuristic = loc => (Rules.Map.ContainsResource(loc) ? 0 : 1),
|
heuristic = loc => (Game.world.Map.ContainsResource(loc) ? 0 : 1),
|
||||||
umt = UnitMovementType.Wheel,
|
umt = UnitMovementType.Wheel,
|
||||||
checkForBlocked = true
|
checkForBlocked = true
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
if (!crushable) return false;
|
if (!crushable) return false;
|
||||||
|
|
||||||
return Rules.Map.IsInMap(a.X, a.Y) &&
|
return Game.world.Map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(GetMovementType(),
|
TerrainCosts.Cost(GetMovementType(),
|
||||||
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace OpenRa.Traits
|
|||||||
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
|
&& underCursor.traits.Contains<AcceptsOre>() && !IsEmpty)
|
||||||
return new Order("Deliver", self, underCursor, int2.Zero, null);
|
return new Order("Deliver", self, underCursor, int2.Zero, null);
|
||||||
|
|
||||||
if (underCursor == null && Rules.Map.ContainsResource(xy))
|
if (underCursor == null && Game.world.Map.ContainsResource(xy))
|
||||||
return new Order("Harvest", self, null, xy, null);
|
return new Order("Harvest", self, null, xy, null);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -106,9 +106,9 @@ namespace OpenRa.Traits
|
|||||||
|
|
||||||
if (!crushable) return false;
|
if (!crushable) return false;
|
||||||
|
|
||||||
return Rules.Map.IsInMap(a.X, a.Y) &&
|
return Game.world.Map.IsInMap(a.X, a.Y) &&
|
||||||
TerrainCosts.Cost(GetMovementType(),
|
TerrainCosts.Cost(GetMovementType(),
|
||||||
Rules.TileSet.GetWalkability(Rules.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
Game.world.TileSet.GetWalkability(Game.world.Map.MapTiles[a.X, a.Y])) < double.PositiveInfinity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<int2> GetCurrentPath()
|
public IEnumerable<int2> GetCurrentPath()
|
||||||
|
|||||||
@@ -45,11 +45,11 @@ namespace OpenRa.Traits
|
|||||||
var p = self.Location + new int2(i % size, i / size + bibOffset);
|
var p = self.Location + new int2(i % size, i / size + bibOffset);
|
||||||
if (isRemove)
|
if (isRemove)
|
||||||
{
|
{
|
||||||
if (Rules.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex))
|
if (Game.world.Map.MapTiles[p.X, p.Y].smudge == (byte)(i + startIndex))
|
||||||
Rules.Map.MapTiles[ p.X, p.Y ].smudge = 0;
|
Game.world.Map.MapTiles[ p.X, p.Y ].smudge = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Rules.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
|
Game.world.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ namespace OpenRa.Traits
|
|||||||
for (var i = -1; i < 2; i++)
|
for (var i = -1; i < 2; i++)
|
||||||
if (Game.SharedRandom.NextDouble() < info.Chance)
|
if (Game.SharedRandom.NextDouble() < info.Chance)
|
||||||
if (Ore.CanSpreadInto(self.Location.X + i, self.Location.Y + j))
|
if (Ore.CanSpreadInto(self.Location.X + i, self.Location.Y + j))
|
||||||
Rules.Map.AddOre(self.Location.X + i, self.Location.Y + j);
|
Game.world.Map.AddOre(self.Location.X + i, self.Location.Y + j);
|
||||||
|
|
||||||
ticks = info.Interval;
|
ticks = info.Interval;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace OpenRa
|
|||||||
|
|
||||||
foreach( var t in Footprint.Tiles( name, bi, position ) )
|
foreach( var t in Footprint.Tiles( name, bi, position ) )
|
||||||
spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound
|
spriteRenderer.DrawSprite( ( isCloseEnough && Game.IsCellBuildable( t, bi.WaterBound
|
||||||
? UnitMovementType.Float : UnitMovementType.Wheel ) && !Rules.Map.ContainsResource( t ) )
|
? UnitMovementType.Float : UnitMovementType.Wheel ) && !Game.world.Map.ContainsResource( t ) )
|
||||||
? buildOk : buildBlocked, Game.CellSize * t, 0 );
|
? buildOk : buildBlocked, Game.CellSize * t, 0 );
|
||||||
|
|
||||||
spriteRenderer.Flush();
|
spriteRenderer.Flush();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using OpenRa.Effects;
|
using OpenRa.Effects;
|
||||||
using OpenRa.Support;
|
using OpenRa.Support;
|
||||||
|
using OpenRa.FileFormats;
|
||||||
|
|
||||||
namespace OpenRa
|
namespace OpenRa
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,16 @@ namespace OpenRa
|
|||||||
List<IEffect> effects = new List<IEffect>();
|
List<IEffect> effects = new List<IEffect>();
|
||||||
List<Action<World>> frameEndActions = new List<Action<World>>();
|
List<Action<World>> frameEndActions = new List<Action<World>>();
|
||||||
|
|
||||||
|
public readonly Map Map;
|
||||||
|
public readonly TileSet TileSet;
|
||||||
|
|
||||||
|
public World()
|
||||||
|
{
|
||||||
|
Map = new Map( Rules.AllRules );
|
||||||
|
FileSystem.MountTemporary( new Package( Map.Theater + ".mix" ) );
|
||||||
|
TileSet = new TileSet( Map.TileSuffix );
|
||||||
|
}
|
||||||
|
|
||||||
public void Add(Actor a)
|
public void Add(Actor a)
|
||||||
{
|
{
|
||||||
a.IsInWorld = true;
|
a.IsInWorld = true;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 10.00
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
# Visual Studio 2008
|
# Visual C# Express 2008
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.FileFormats", "OpenRa.FileFormats\OpenRa.FileFormats.csproj", "{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.FileFormats", "OpenRa.FileFormats\OpenRa.FileFormats.csproj", "{BDAEAB25-991E-46A7-AF1E-4F0E03358DAA}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Game", "OpenRa.Game\OpenRa.Game.csproj", "{0DFB103F-2962-400F-8C6D-E2C28CCBA633}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Game", "OpenRa.Game\OpenRa.Game.csproj", "{0DFB103F-2962-400F-8C6D-E2C28CCBA633}"
|
||||||
@@ -17,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RulesConverter", "RulesConv
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.RA", "OpenRa.Mods.RA\OpenRa.Mods.RA.csproj", "{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.RA", "OpenRa.Mods.RA\OpenRa.Mods.RA.csproj", "{4A8A43B5-A9EF-4ED0-99DD-4BAB10A0DB6E}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Mods", "Mods", "{F80861C1-DD5C-40A4-94B4-02D96318AE95}"
|
|
||||||
EndProject
|
|
||||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.Aftermath", "OpenRa.Mods.Aftermath\OpenRa.Mods.Aftermath.csproj", "{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}"
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenRa.Mods.Aftermath", "OpenRa.Mods.Aftermath\OpenRa.Mods.Aftermath.csproj", "{2E1F8D8B-AEF5-4BCE-A95C-50223A0C7331}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
|
|||||||
Reference in New Issue
Block a user