diff --git a/OpenRA.Mods.Common/Traits/Buildings/Building.cs b/OpenRA.Mods.Common/Traits/Buildings/Building.cs index 16d4cd6299..635262db2e 100644 --- a/OpenRA.Mods.Common/Traits/Buildings/Building.cs +++ b/OpenRA.Mods.Common/Traits/Buildings/Building.cs @@ -34,6 +34,12 @@ namespace OpenRA.Mods.Common.Traits public readonly CVec Dimensions = new CVec(1, 1); public readonly bool RequiresBaseProvider = false; public readonly bool AllowInvalidPlacement = false; + [Desc("Clear smudges from underneath the building footprint.")] + public readonly bool RemoveSmudgesOnBuild = true; + [Desc("Clear smudges from underneath the building footprint on sell.")] + public readonly bool RemoveSmudgesOnSell = true; + [Desc("Clear smudges from underneath the building footprint on transform.")] + public readonly bool RemoveSmudgesOnTransform = true; public readonly string[] BuildSounds = { "placbldg.aud", "build5.aud" }; public readonly string[] UndeploySounds = { "cashturn.aud" }; @@ -185,6 +191,9 @@ namespace OpenRA.Mods.Common.Traits public virtual void AddedToWorld(Actor self) { + if (Info.RemoveSmudgesOnBuild) + RemoveSmudges(); + self.World.ActorMap.AddInfluence(self, this); self.World.ActorMap.AddPosition(self, this); @@ -215,6 +224,9 @@ namespace OpenRA.Mods.Common.Traits public void Selling(Actor self) { + if (Info.RemoveSmudgesOnSell) + RemoveSmudges(); + BuildComplete = false; } @@ -222,11 +234,23 @@ namespace OpenRA.Mods.Common.Traits public void BeforeTransform(Actor self) { + if (Info.RemoveSmudgesOnTransform) + RemoveSmudges(); + foreach (var s in Info.UndeploySounds) Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition); } public void OnTransform(Actor self) { } public void AfterTransform(Actor self) { } + + public void RemoveSmudges() + { + var smudgeLayers = self.World.WorldActor.TraitsImplementing(); + + foreach (var smudgeLayer in smudgeLayers) + foreach (var footprintTile in FootprintUtils.Tiles(self)) + smudgeLayer.RemoveSmudge(footprintTile); + } } } diff --git a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs index e3062d2088..1cd7714c12 100644 --- a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs @@ -142,7 +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))); - if (!dirty.ContainsKey(loc) && !tiles.ContainsKey(loc)) + if ((!dirty.ContainsKey(loc) || dirty[loc].Sprite == null) && !tiles.ContainsKey(loc)) { // No smudge; create a new one var st = smudges.Keys.Random(world.SharedRandom); @@ -163,6 +163,22 @@ namespace OpenRA.Mods.Common.Traits } } + public void RemoveSmudge(CPos loc) + { + if (dirty.ContainsKey(loc)) + { + var tile = dirty[loc]; + tile.Depth = 0; + tile.Sprite = null; + dirty[loc] = tile; + } + else + { + var st = smudges.Keys.Random(world.SharedRandom); + dirty[loc] = new Smudge { Type = st, Depth = 0, Sprite = null }; + } + } + public void TickRender(WorldRenderer wr, Actor self) { var remove = new List(); @@ -170,7 +186,10 @@ namespace OpenRA.Mods.Common.Traits { if (!self.World.FogObscures(kv.Key)) { - tiles[kv.Key] = kv.Value; + if (kv.Value.Sprite == null) + tiles.Remove(kv.Key); + else + tiles[kv.Key] = kv.Value; render.Update(kv.Key, kv.Value.Sprite); remove.Add(kv.Key); diff --git a/mods/d2k/tilesets/arrakis.yaml b/mods/d2k/tilesets/arrakis.yaml index 14d10a114d..209e1dba52 100644 --- a/mods/d2k/tilesets/arrakis.yaml +++ b/mods/d2k/tilesets/arrakis.yaml @@ -19,6 +19,7 @@ Terrain: TerrainType@Concrete: Type: Concrete TargetTypes: Ground + AcceptsSmudgeType: RockCrater Color: E8C498 TerrainType@Dune: Type: Dune