Fix SmudgeLayer style nits.
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
#region Copyright & License Information
|
#region Copyright & License Information
|
||||||
/*
|
/*
|
||||||
* Copyright 2007-2011 The OpenRA Developers (see AUTHORS)
|
* Copyright 2007-2013 The OpenRA Developers (see AUTHORS)
|
||||||
* This file is part of OpenRA, which is free software. It is made
|
* This file is part of OpenRA, which is free software. It is made
|
||||||
* available to you under the terms of the GNU General Public License
|
* available to you under the terms of the GNU General Public License
|
||||||
* as published by the Free Software Foundation. For more information,
|
* as published by the Free Software Foundation. For more information,
|
||||||
@@ -14,22 +14,22 @@ using System.Drawing;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using OpenRA.FileFormats;
|
using OpenRA.FileFormats;
|
||||||
using OpenRA.Graphics;
|
using OpenRA.Graphics;
|
||||||
using OpenRA.Traits;
|
|
||||||
using OpenRA.Mods.RA.Effects;
|
using OpenRA.Mods.RA.Effects;
|
||||||
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
public class SmudgeLayerInfo : ITraitInfo
|
public class SmudgeLayerInfo : ITraitInfo
|
||||||
{
|
{
|
||||||
public readonly string Type = "Scorch";
|
public readonly string Type = "Scorch";
|
||||||
public readonly string[] Types = {"sc1", "sc2", "sc3", "sc4", "sc5", "sc6"};
|
public readonly string[] Types = { "sc1", "sc2", "sc3", "sc4", "sc5", "sc6" };
|
||||||
public readonly int[] Depths = {1,1,1,1,1,1};
|
public readonly int[] Depths = { 1, 1, 1, 1, 1, 1 };
|
||||||
public readonly int SmokePercentage = 25;
|
public readonly int SmokePercentage = 25;
|
||||||
public readonly string SmokeType = "smoke_m";
|
public readonly string SmokeType = "smoke_m";
|
||||||
public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
|
public object Create(ActorInitializer init) { return new SmudgeLayer(this); }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class SmudgeLayer: IRenderOverlay, IWorldLoaded
|
public class SmudgeLayer : IRenderOverlay, IWorldLoaded
|
||||||
{
|
{
|
||||||
public SmudgeLayerInfo Info;
|
public SmudgeLayerInfo Info;
|
||||||
Dictionary<CPos, TileReference<byte, byte>> tiles;
|
Dictionary<CPos, TileReference<byte, byte>> tiles;
|
||||||
@@ -48,26 +48,27 @@ namespace OpenRA.Mods.RA
|
|||||||
tiles = new Dictionary<CPos, TileReference<byte, byte>>();
|
tiles = new Dictionary<CPos, TileReference<byte, byte>>();
|
||||||
|
|
||||||
// Add map smudges
|
// Add map smudges
|
||||||
foreach (var s in w.Map.Smudges.Value.Where( s => Info.Types.Contains(s.Type )))
|
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), (byte)s.Depth));
|
tiles.Add((CPos)s.Location, new TileReference<byte, byte>((byte)Array.IndexOf(Info.Types, s.Type), (byte)s.Depth));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AddSmudge(CPos loc)
|
public void AddSmudge(CPos loc)
|
||||||
{
|
{
|
||||||
if (Game.CosmeticRandom.Next(0,100) <= Info.SmokePercentage)
|
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
|
||||||
world.AddFrameEndTask(w => w.Add(new Smoke(w, loc.CenterPosition, Info.SmokeType)));
|
world.AddFrameEndTask(w => w.Add(new Smoke(w, loc.CenterPosition, Info.SmokeType)));
|
||||||
|
|
||||||
// No smudge; create a new one
|
// No smudge; create a new one
|
||||||
if (!tiles.ContainsKey(loc))
|
if (!tiles.ContainsKey(loc))
|
||||||
{
|
{
|
||||||
byte st = (byte)(1 + world.SharedRandom.Next(Info.Types.Length - 1));
|
byte st = (byte)(1 + world.SharedRandom.Next(Info.Types.Length - 1));
|
||||||
tiles.Add(loc, new TileReference<byte,byte>(st,(byte)0));
|
tiles.Add(loc, new TileReference<byte, byte>(st, (byte)0));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var tile = tiles[loc];
|
var tile = tiles[loc];
|
||||||
|
|
||||||
// Existing smudge; make it deeper
|
// Existing smudge; make it deeper
|
||||||
int depth = Info.Depths[tile.type-1];
|
var depth = Info.Depths[tile.type - 1];
|
||||||
if (tile.index < depth - 1)
|
if (tile.index < depth - 1)
|
||||||
{
|
{
|
||||||
tile.index++;
|
tile.index++;
|
||||||
@@ -75,20 +76,20 @@ namespace OpenRA.Mods.RA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Render( WorldRenderer wr )
|
public void Render(WorldRenderer wr)
|
||||||
{
|
{
|
||||||
var cliprect = Game.viewport.WorldBounds(world);
|
var cliprect = Game.viewport.WorldBounds(world);
|
||||||
var pal = wr.Palette("terrain");
|
var pal = wr.Palette("terrain");
|
||||||
|
|
||||||
foreach (var kv in tiles)
|
foreach (var kv in tiles)
|
||||||
{
|
{
|
||||||
if (!cliprect.Contains(kv.Key.X,kv.Key.Y))
|
if (!cliprect.Contains(kv.Key.X, kv.Key.Y))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (world.ShroudObscures(kv.Key))
|
if (world.ShroudObscures(kv.Key))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
smudgeSprites[kv.Value.type- 1][kv.Value.index].DrawAt(kv.Key.ToPPos().ToFloat2(), pal);
|
smudgeSprites[kv.Value.type - 1][kv.Value.index].DrawAt(kv.Key.ToPPos().ToFloat2(), pal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user