From c92a6be4af14c431482899d67054ce34a1c5b5cc Mon Sep 17 00:00:00 2001 From: Ashley Newson Date: Sun, 18 May 2025 18:44:49 +0100 Subject: [PATCH] Respect MultiBrush weights when path tiling Allows biasing path tiling towards or away from using certain MultiBrushes using their existing weight property. Note that the probability of brush selection depends on multiple factors, not just their direct weight. --- OpenRA.Mods.Common/MapGenerator/TilingPath.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/MapGenerator/TilingPath.cs b/OpenRA.Mods.Common/MapGenerator/TilingPath.cs index 2e03c05cec..85453d77be 100644 --- a/OpenRA.Mods.Common/MapGenerator/TilingPath.cs +++ b/OpenRA.Mods.Common/MapGenerator/TilingPath.cs @@ -803,7 +803,10 @@ namespace OpenRA.Mods.Common.MapGenerator } Debug.Assert(candidates.Count >= 1, "TraceBack didn't find an original route"); - var chosenSegment = candidates[random.Next(candidates.Count)]; + var weights = candidates + .Select(c => c.MultiBrush.Weight) + .ToArray(); + var chosenSegment = candidates[random.PickWeighted(weights)]; var chosenFrom = to - chosenSegment.Moves; compositeBrush.MergeFrom( chosenSegment.MultiBrush,