Add comments explaining the special meaning of a null Sprite in SmudgeLayer

This commit is contained in:
Oliver Brakmann
2016-08-30 20:11:13 +02:00
parent 0ebf2d00b0
commit 93dba184a1

View File

@@ -142,6 +142,7 @@ namespace OpenRA.Mods.Common.Traits
if (Game.CosmeticRandom.Next(0, 100) <= Info.SmokePercentage)
world.AddFrameEndTask(w => w.Add(new SpriteEffect(world.Map.CenterOfCell(loc), w, Info.SmokeType, Info.SmokeSequence, Info.SmokePalette)));
// A null Sprite indicates a deleted smudge.
if ((!dirty.ContainsKey(loc) || dirty[loc].Sprite == null) && !tiles.ContainsKey(loc))
{
// No smudge; create a new one
@@ -151,6 +152,7 @@ namespace OpenRA.Mods.Common.Traits
else
{
// Existing smudge; make it deeper
// A null Sprite indicates a deleted smudge.
var tile = dirty.ContainsKey(loc) && dirty[loc].Sprite != null ? dirty[loc] : tiles[loc];
var maxDepth = smudges[tile.Type].Length;
if (tile.Depth < maxDepth - 1)
@@ -167,6 +169,7 @@ namespace OpenRA.Mods.Common.Traits
{
var tile = dirty.ContainsKey(loc) ? dirty[loc] : new Smudge();
// Setting Sprite to null to indicate a deleted smudge.
tile.Sprite = null;
dirty[loc] = tile;
}
@@ -178,6 +181,7 @@ namespace OpenRA.Mods.Common.Traits
{
if (!self.World.FogObscures(kv.Key))
{
// A null Sprite indicates a deleted smudge.
if (kv.Value.Sprite == null)
tiles.Remove(kv.Key);
else