cnc map tib support

This commit is contained in:
Paul Chote
2010-03-04 10:17:59 +13:00
parent 6ad23a191d
commit 1914a8adbe
5 changed files with 51 additions and 12 deletions

View File

@@ -86,6 +86,7 @@ namespace OpenRA.FileFormats
else // CNC
{
UnpackCncTileData(FileSystem.Open(filename.Substring(0,filename.Length-4)+".bin"));
ReadCncOverlay(file);
ReadCncTrees(file);
}
@@ -171,7 +172,7 @@ namespace OpenRA.FileFormats
}
}
static string[] overlaySpriteNames =
static string[] raOverlayNames =
{
"sbag", "cycl", "brik", "fenc", "wood",
"gold01", "gold02", "gold03", "gold04",
@@ -186,7 +187,7 @@ namespace OpenRA.FileFormats
for( int j = 0 ; j < MapSize ; j++ )
{
byte o = ReadByte( ms );
MapTiles[ j, i ].overlay = (o == 255) ? null : overlaySpriteNames[o];
MapTiles[ j, i ].overlay = (o == 255) ? null : raOverlayNames[o];
}
}
@@ -215,7 +216,24 @@ namespace OpenRA.FileFormats
MapTiles[ j, i ].image = (byte)( i % 4 + ( j % 4 ) * 4 );
}
}
void ReadCncOverlay( IniFile file )
{
IniSection overlay = file.GetSection( "OVERLAY", true );
if( overlay == null )
return;
foreach( KeyValuePair<string, string> kv in overlay )
{
var loc = int.Parse( kv.Key );
int2 cell = new int2(loc % MapSize, loc / MapSize);
Log.Write("Overlay {0} at ({1},{2})",kv.Value,cell.X,cell.Y);
MapTiles[ cell.X, cell.Y ].overlay = kv.Value.ToLower();
}
}
void ReadCncTrees( IniFile file )
{
IniSection terrain = file.GetSection( "TERRAIN", true );

View File

@@ -34,9 +34,7 @@ namespace OpenRA
Sprite[] shadowBits = SpriteSheetBuilder.LoadAllSprites("shadow");
Sprite[,] sprites = new Sprite[128, 128];
bool dirty = true;
// TODO: Testing
bool hasGPS = true;
bool hasGPS = false;
Player owner;
Map map;
public Rectangle? bounds;

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.
@@ -35,7 +35,7 @@ namespace OpenRA.Traits
World w;
public ResourceTypeInfo[] resourceTypes;
CellContents[,] content = new CellContents[128, 128];
CellContents[,] content;
public ResourceLayer(Actor self)
{
@@ -65,6 +65,8 @@ namespace OpenRA.Traits
public void WorldLoaded(World w)
{
this.w = w;
content = new CellContents[w.Map.MapSize, w.Map.MapSize];
resourceTypes = w.WorldActor.Info.Traits.WithInterface<ResourceTypeInfo>().ToArray();
foreach (var rt in resourceTypes)
rt.Sprites = rt.SpriteNames.Select(a => SpriteSheetBuilder.LoadAllSprites(a)).ToArray();

View File

@@ -177,12 +177,31 @@ World:
Race: nod
SellButton:
RepairButton:
ChoosePaletteOnSelect:
WallLoadHook@sbag:
ActorType: sbag
OverlayTypes: sbag
WallLoadHook@cycl:
ActorType: cycl
OverlayTypes: cycl
WallLoadHook@brik:
ActorType: brik
OverlayTypes: brik
WallLoadHook@fenc:
ActorType: fenc
OverlayTypes: fenc
WallLoadHook@wood:
ActorType: wood
OverlayTypes: wood
WallLoadHook@barb:
ActorType: barb
OverlayTypes: barb
ResourceLayer:
ResourceType@green-tib:
Overlays: 5,6,7,8,9,10,11,12
Overlays: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
Palette: player
SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12
ValuePerUnit: 30
Name: Tiberium
GrowthInterval: .1
SpreadInterval: .1
GrowthInterval: 1
SpreadInterval: 6

View File

@@ -2,13 +2,15 @@ SPLIT2:
Inherits: ^Building
RenderBuilding:
Palette: terrain
SeedsOre:
SeedsResource:
ResourceType:Tiberium
-Selectable:
SPLIT3:
Inherits: ^Building
RenderBuilding:
Palette: terrain
SeedsOre:
SeedsResource:
ResourceType:Tiberium
-Selectable:
ROCK1:
Inherits: ^Tree