From 1f10dafbeac9fd7746da34dda1e8645148ca1335 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Sun, 23 Aug 2020 13:22:26 +0200 Subject: [PATCH] Add MaxSmokeOffsetDistance to SmudgeLayer --- OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs index 6ea51afb84..8ffee62c19 100644 --- a/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs +++ b/OpenRA.Mods.Common/Traits/World/SmudgeLayer.cs @@ -38,6 +38,10 @@ namespace OpenRA.Mods.Common.Traits [Desc("Chance of smoke rising from the ground")] public readonly int SmokeChance = 0; + [Desc("By how much (in each direction) can the smoke appearance offset stray from the center of the cell?", + "Note: Limit this to half a cell for square and 1/3 a cell for isometric cells to avoid straying into neighbour cells.")] + public readonly WDist MaxSmokeOffsetDistance = WDist.Zero; + [Desc("Smoke sprite image name")] public readonly string SmokeImage = null; @@ -152,8 +156,19 @@ namespace OpenRA.Mods.Common.Traits return; if (hasSmoke && Game.CosmeticRandom.Next(0, 100) <= Info.SmokeChance) + { + var maxOffsetDistance = Info.MaxSmokeOffsetDistance.Length; + + // TODO: With offset added height is not accurate for TS maps + var position = world.Map.CenterOfCell(loc); + if (maxOffsetDistance != 0) + position += new WVec(Game.CosmeticRandom.Next(-maxOffsetDistance, maxOffsetDistance), + Game.CosmeticRandom.Next(-maxOffsetDistance, maxOffsetDistance), + 0); + world.AddFrameEndTask(w => w.Add(new SpriteEffect( - w.Map.CenterOfCell(loc), w, Info.SmokeImage, Info.SmokeSequences.Random(w.SharedRandom), Info.SmokePalette))); + position, w, Info.SmokeImage, Info.SmokeSequences.Random(Game.CosmeticRandom), Info.SmokePalette))); + } // A null Sequence indicates a deleted smudge. if ((!dirty.ContainsKey(loc) || dirty[loc].Sequence == null) && !tiles.ContainsKey(loc))