Merge pull request #4271 from pchote/smudges

Use original D2K craters.
This commit is contained in:
Matthias Mailänder
2013-12-11 04:39:07 -08:00
13 changed files with 143 additions and 32 deletions

View File

@@ -73,7 +73,7 @@ NEW:
Added cash tick sounds.
Disabled the main menu target reticle showing when a window is open.
Added a display of the faction logos when the shellmap is disabled.
Visceriods now heal on Tiberium and move faster there.
Viceroids now heal on and move faster on Tiberium.
Implemented the original shroud artwork.
Dune 2000:
Added buildable concrete walls.
@@ -143,6 +143,7 @@ NEW:
Unified sprite loading allows any sprite type to be used anywhere: shp can now be used for terrain, and tmp for units.
Harvestable resource definitions (ResourceTypes) have changed, and now specify their artwork using sequences.
Shroud definitions (ShroudRenderer / ShroudPalette) have changed, and now specifies its artwork using sequences.
Crater and smudge definitions (SmudgeLayer) have changed, and now specify their artwork using sequences.
20130915:
All mods:

View File

@@ -68,5 +68,14 @@ namespace OpenRA.Graphics
return units[unit].ContainsKey(seq);
}
public static IEnumerable<string> Sequences(string unit)
{
if (!units.ContainsKey(unit))
throw new InvalidOperationException(
"Unit `{0}` does not have all sequences defined.".F(unit));
return units[unit].Keys;
}
}
}

View File

@@ -21,36 +21,61 @@ namespace OpenRA.Mods.RA
public class SmudgeLayerInfo : ITraitInfo
{
public readonly string Type = "Scorch";
public readonly string[] Types = { "sc1", "sc2", "sc3", "sc4", "sc5", "sc6" };
public readonly int[] Depths = { 1, 1, 1, 1, 1, 1 };
public readonly string Sequence = "scorch";
public readonly int SmokePercentage = 25;
public readonly string SmokeType = "smoke_m";
public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
}
public class SmudgeLayer : IRenderOverlay, IWorldLoaded, ITickRender
{
struct Smudge
{
public string Type;
public int Depth;
public Sprite Sprite;
}
public SmudgeLayerInfo Info;
Dictionary<CPos, TileReference<byte, byte>> tiles;
Dictionary<CPos, TileReference<byte, byte>> dirty;
Sprite[][] smudgeSprites;
Dictionary<CPos, Smudge> tiles;
Dictionary<CPos, Smudge> dirty;
Dictionary<string, Sprite[]> smudges;
World world;
public SmudgeLayer(SmudgeLayerInfo info)
{
this.Info = info;
smudgeSprites = Info.Types.Select(x => Game.modData.SpriteLoader.LoadAllSprites(x)).ToArray();
}
public void WorldLoaded(World w, WorldRenderer wr)
{
world = w;
tiles = new Dictionary<CPos, TileReference<byte, byte>>();
dirty = new Dictionary<CPos, TileReference<byte, byte>>();
tiles = new Dictionary<CPos, Smudge>();
dirty = new Dictionary<CPos, Smudge>();
smudges = new Dictionary<string, Sprite[]>();
var types = SequenceProvider.Sequences(Info.Sequence);
foreach (var t in types)
{
var seq = SequenceProvider.GetSequence(Info.Sequence, t);
var sprites = Exts.MakeArray(seq.Length, x => seq.GetSprite(x));
smudges.Add(t, sprites);
}
// Add map smudges
foreach (var s in w.Map.Smudges.Value.Where(s => Info.Types.Contains(s.Type)))
tiles.Add((CPos)s.Location, new TileReference<byte, byte>((byte)(Array.IndexOf(Info.Types, s.Type) + 1), (byte)s.Depth));
foreach (var s in w.Map.Smudges.Value.Where(s => smudges.Keys.Contains(s.Type)))
{
var smudge = new Smudge
{
Type = s.Type,
Depth = s.Depth,
Sprite = smudges[s.Type][s.Depth]
};
tiles.Add((CPos)s.Location, smudge);
}
}
public void AddSmudge(CPos loc)
@@ -61,16 +86,19 @@ namespace OpenRA.Mods.RA
if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc))
{
// No smudge; create a new one
var st = (byte)(1 + world.SharedRandom.Next(Info.Types.Length - 1));
dirty[loc] = new TileReference<byte, byte>(st, (byte)0);
var st = smudges.Keys.Random(world.SharedRandom);
dirty[loc] = new Smudge { Type = st, Depth = 0, Sprite = smudges[st][0] };
}
else
{
// Existing smudge; make it deeper
var tile = dirty.ContainsKey(loc) ? dirty[loc] : tiles[loc];
var depth = Info.Depths[tile.Type - 1];
if (tile.Index < depth - 1)
tile.Index++;
var maxDepth = smudges[tile.Type].Length;
if (tile.Depth < maxDepth - 1)
{
tile.Depth++;
tile.Sprite = smudges[tile.Type][tile.Depth];
}
dirty[loc] = tile;
}
@@ -105,8 +133,7 @@ namespace OpenRA.Mods.RA
if (world.ShroudObscures(kv.Key))
continue;
var tile = smudgeSprites[kv.Value.Type - 1][kv.Value.Index];
new SpriteRenderable(tile, kv.Key.CenterPosition,
new SpriteRenderable(kv.Value.Sprite, kv.Key.CenterPosition,
WVec.Zero, -511, pal, 1f, true).Render(wr);
}
}

View File

@@ -313,13 +313,11 @@ World:
AllowUnderActors: false
SmudgeLayer@SCORCH:
Type:Scorch
Sequence: scorches
SmokePercentage:50
Types:sc1,sc2,sc3,sc4,sc5,sc6
Depths:1,1,1,1,1,1
SmudgeLayer@CRATER:
Type:Crater
Types:cr1,cr2,cr3,cr4,cr5,cr6
Depths:5,5,5,5,5,5
Sequence: craters
PathfinderDebugOverlay:
SpawnMapActors:
MPStartLocations:

View File

@@ -374,4 +374,34 @@ shroud:
Length: 12
typed: shadow
Start: 36
Length: 12
Length: 12
# Note: The order of smudges and craters determines
# the index that is mapped to them in maps
scorches:
sc1: sc1
Length: *
sc2: sc2
Length: *
sc3: sc3
Length: *
sc4: sc4
Length: *
sc5: sc5
Length: *
sc6: sc6
Length: *
craters:
cr1: cr1
Length: *
cr2: cr2
Length: *
cr3: cr3
Length: *
cr4: cr4
Length: *
cr5: cr5
Length: *
cr6: cr6
Length: *

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -463,13 +463,11 @@ World:
AllowUnderActors: false
SmudgeLayer@Rock:
Type: RockCrater
Types: rockcrater1, rockcrater2
Depths: 15, 15
Sequence: rockcraters
SmokePercentage: 0
SmudgeLayer@Sand:
Type: SandCrater
Types: sandcrater1, sandcrater2
Depths: 15, 15
Sequence: sandcraters
SmokePercentage: 0
SpawnMapActors:
CreateMPPlayers:

View File

@@ -333,3 +333,23 @@ shroud:
Length: 14
Offset: -16,-16
BlendMode: Multiply
rockcraters:
rockcrater1: DATA
Start: 114
Length: 16
Offset: -16,-16
rockcrater2: DATA
Start: 130
Length: 16
Offset: -16,-16
sandcraters:
sandcrater1: DATA
Start: 146
Length: 16
Offset: -16,-16
sandcrater2: DATA
Start: 162
Length: 16
Offset: -16,-16

View File

@@ -655,13 +655,11 @@ World:
TerrainType: Gems
SmudgeLayer@SCORCH:
Type:Scorch
Sequence: scorches
SmokePercentage:50
Types:sc1,sc2,sc3,sc4,sc5,sc6
Depths:1,1,1,1,1,1
SmudgeLayer@CRATER:
Type:Crater
Types:cr1,cr2,cr3,cr4,cr5,cr6
Depths:5,5,5,5,5,5
Sequence: craters
PathfinderDebugOverlay:
SpawnMapActors:
CreateMPPlayers:

View File

@@ -490,4 +490,34 @@ resources:
shroud:
shroud: shadow
Length: *
Length: *
# Note: The order of smudges and craters determines
# the index that is mapped to them in maps
scorches:
sc1: sc1
Length: *
sc2: sc2
Length: *
sc3: sc3
Length: *
sc4: sc4
Length: *
sc5: sc5
Length: *
sc6: sc6
Length: *
craters:
cr1: cr1
Length: *
cr2: cr2
Length: *
cr3: cr3
Length: *
cr4: cr4
Length: *
cr5: cr5
Length: *
cr6: cr6
Length: *