Game uses new format. Missing bridges/resources/smudges. Buggy map bounds, actor placement and tile images.

This commit is contained in:
Paul Chote
2010-04-01 19:13:26 +13:00
committed by Bob
parent 382efbcdfb
commit f7e2f414c0
20 changed files with 187 additions and 101 deletions

View File

@@ -113,7 +113,7 @@ namespace OpenRA
LoadModPackages(manifest);
Rules.LoadRules(mapName, manifest);
Rules.LoadRules(manifest);
Timer.Time( "load rules: {0}" );
world = null; // trying to access the old world will NRE, rather than silently doing it wrong.

View File

@@ -35,8 +35,8 @@ namespace OpenRA
public static Dictionary<string, VoiceInfo> Voices;
public static Dictionary<TerrainType, TerrainCost> TerrainTypes;
public static void LoadRules(string map, Manifest m)
{
public static void LoadRules(Manifest m)
{
Log.Write("Using rules files: ");
foreach (var y in m.Rules)
Log.Write(" -- {0}", y);

View File

@@ -41,7 +41,7 @@ namespace OpenRA.GameRules
// External game settings
public readonly string NetworkHost = "";
public readonly int NetworkPort = 0;
public readonly string Map = "scm02ea.ini";
public readonly string Map = "mods/ra/testmap.yaml";
public readonly int Player = 1;
public readonly string Replay = "";
public readonly string PlayerName = "";

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.
@@ -46,6 +46,7 @@ namespace OpenRA.Graphics
public void Draw()
{
/*
var shroud = Game.world.LocalPlayer.Shroud;
for (int y = map.YOffset; y < map.YOffset + map.Height; y++)
@@ -63,6 +64,7 @@ namespace OpenRA.Graphics
}
spriteRenderer.Flush();
*/
}
}
}

View File

@@ -42,7 +42,7 @@ namespace OpenRA.Graphics
Size tileSize = new Size( Game.CellSize, Game.CellSize );
var tileMapping = new Cache<TileReference, Sprite>(
var tileMapping = new Cache<TileReference<ushort,byte>, Sprite>(
x => SheetBuilder.SharedInstance.Add(world.TileSet.GetBytes(x), tileSize));
Vertex[] vertices = new Vertex[4 * map.Height * map.Width];

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.
@@ -31,22 +31,25 @@ namespace OpenRA
public static void AddSmudge(this Map map, bool isCrater, int x, int y)
{
/*
var smudge = map.MapTiles[x, y].smudge;
if (smudge == 0)
map.MapTiles[x, y].smudge = (byte) (isCrater
? (firstCrater + framesPerCrater * ChooseSmudge())
: (firstScorch + ChooseSmudge()));
if (smudge < firstCrater || !isCrater) return; /* bib or scorch; don't change */
if (smudge < firstCrater || !isCrater) return; / * bib or scorch; don't change * /
/* deepen the crater */
/ * deepen the crater * /
var amount = (smudge - firstCrater) % framesPerCrater;
if (amount < framesPerCrater - 1)
map.MapTiles[x, y].smudge++;
*/
}
public static void AddSmudge(this Map map, int2 targetTile, WarheadInfo warhead)
{
/*
if (warhead.SmudgeType == SmudgeType.None) return;
if (warhead.Size[0] == 0 && warhead.Size[1] == 0)
map.AddSmudge(warhead.SmudgeType == SmudgeType.Crater, targetTile.X, targetTile.Y);
@@ -55,9 +58,10 @@ namespace OpenRA
if ((t - targetTile).LengthSquared >= warhead.Size[1] * warhead.Size[1])
if (Rules.TerrainTypes[Game.world.GetTerrainType(t)].AcceptSmudge)
map.AddSmudge(warhead.SmudgeType == SmudgeType.Crater, t.X, t.Y);
*/
}
static int lastSmudge = 0;
static int ChooseSmudge() { lastSmudge = (lastSmudge + 1) % 6; return lastSmudge; }
static int ChooseSmudge() { return 0; /*lastSmudge = (lastSmudge + 1) % 6; return lastSmudge; */}
}
}

View File

@@ -36,8 +36,10 @@ namespace OpenRA.Traits
public object Create(Actor self) { return new Bridge(self); }
}
class Bridge : IRender, ICustomTerrain, INotifyDamage
class Bridge // : IRender, ICustomTerrain, INotifyDamage
{
public Bridge(Actor self) { }
/*
Dictionary<int2, int> Tiles;
List<Dictionary<int2, Sprite>> TileSprites = new List<Dictionary<int2,Sprite>>();
List<TileTemplate> Templates = new List<TileTemplate>();
@@ -47,7 +49,7 @@ namespace OpenRA.Traits
Bridge northNeighbour, southNeighbour;
public Bridge(Actor self) { this.self = self; self.RemoveOnDeath = false; }
static string cachedTheater;
static Cache<TileReference, Sprite> sprites;
@@ -169,5 +171,6 @@ namespace OpenRA.Traits
if (southNeighbour != null) southNeighbour.UpdateState();
}
}
*/
}
}

View File

@@ -58,6 +58,7 @@ namespace OpenRA.Traits
void DoBib(Actor self, bool isRemove)
{
/*
var buildingInfo = self.Info.Traits.Get<BuildingInfo>();
if (buildingInfo.Bib)
{
@@ -77,6 +78,7 @@ namespace OpenRA.Traits
self.World.Map.MapTiles[p.X, p.Y].smudge = (byte)(i + startIndex);
}
}
*/
}
protected string GetPrefix(Actor self)

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.
@@ -25,9 +25,9 @@ namespace OpenRA.Traits
{
class BridgeLoadHookInfo : StatelessTraitInfo<BridgeLoadHook> { }
class BridgeLoadHook : ILoadWorldHook
class BridgeLoadHook// : ILoadWorldHook
{
static void MakeBridges(World w)
/*static void MakeBridges(World w)
{
var mini = w.Map.XOffset; var maxi = w.Map.XOffset + w.Map.Width;
var minj = w.Map.YOffset; var maxj = w.Map.YOffset + w.Map.Height;
@@ -40,7 +40,7 @@ namespace OpenRA.Traits
foreach (var br in w.Actors.SelectMany(a => a.traits.WithInterface<Bridge>()))
br.FinalizeBridges(w);
}
static void ConvertBridgeToActor(World w, int i, int j)
{
var tile = w.Map.MapTiles[i, j].tile;
@@ -84,5 +84,6 @@ namespace OpenRA.Traits
}
public void WorldLoaded(World w) { MakeBridges(w); }
*/
}
}

View File

@@ -29,8 +29,16 @@ namespace OpenRA.Traits
public object Create(Actor self) { return new ResourceLayer(self); }
}
public class ResourceLayer : IRenderOverlay, ILoadWorldHook
class ResourceLayer// : IRenderOverlay, ILoadWorldHook
{
public ResourceLayer(Actor self) {}
public void Destroy(int2 p){}
public ResourceTypeInfo GetResource(int2 p) {return null;}
public ResourceTypeInfo Harvest(int2 p) {return null;}
public void AddResource(ResourceTypeInfo info, int i, int j, int n) {}
public void Grow(ResourceTypeInfo info) {}
public void Spread(ResourceTypeInfo info) {}
/*
SpriteRenderer sr;
World w;
@@ -41,7 +49,7 @@ namespace OpenRA.Traits
{
sr = new SpriteRenderer( Game.renderer, true );
}
public void Render()
{
var shroud = Game.world.LocalPlayer.Shroud;
@@ -87,7 +95,7 @@ namespace OpenRA.Traits
if (content[x, y].type != null)
content[x, y].density = GetIdealDensity(x, y);
}
public Sprite[] ChooseContent(ResourceTypeInfo info)
{
return info.Sprites[w.SharedRandom.Next(info.Sprites.Length)];
@@ -187,6 +195,7 @@ namespace OpenRA.Traits
content[i, j].image = ChooseContent(info);
content[i, j].density = 0;
}
}
public ResourceTypeInfo GetResource(int2 p) { return content[p.X, p.Y].type; }
@@ -197,5 +206,6 @@ namespace OpenRA.Traits
public Sprite[] image;
public int density;
}
*/
}
}

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -12,10 +12,10 @@ namespace OpenRA.Traits
public void GameStarted(World world)
{
Game.skipMakeAnims = true; // rude hack
// TODO: Keep a dictionary of actor reference -> actor somewhere for scripting purposes
foreach (var actorReference in world.Map.Actors)
world.CreateActor(actorReference.Name, actorReference.Location,
world.players.Values.FirstOrDefault(p => p.InternalName == actorReference.Owner)
world.CreateActor(actorReference.Value.Name, actorReference.Value.Location,
world.players.Values.FirstOrDefault(p => p.InternalName == actorReference.Value.Owner)
?? world.NeutralPlayer);
Game.skipMakeAnims = false;

View File

@@ -13,11 +13,11 @@ namespace OpenRA.Traits
public object Create(Actor self) { return new WallLoadHook( self, this ); }
}
class WallLoadHook : IGameStarted
class WallLoadHook // : IGameStarted
{
WallLoadHookInfo info;
public WallLoadHook(Actor self, WallLoadHookInfo info) { this.info = info; }
/*
public void GameStarted(World w)
{
var map = w.Map;
@@ -27,5 +27,6 @@ namespace OpenRA.Traits
if (info.OverlayTypes.Contains(w.Map.MapTiles[x, y].overlay))
w.CreateActor(info.ActorType, new int2(x, y), w.NeutralPlayer);
}
*/
}
}