Fix TryFindRandomTile grid weighting (#27724)

This commit is contained in:
Kara
2024-05-06 04:25:11 -07:00
committed by GitHub
parent 8fa7ea7cf9
commit aaabd5e914
2 changed files with 18 additions and 8 deletions

View File

@@ -57,7 +57,8 @@ namespace Content.Shared.Random.Helpers
throw new InvalidOperationException($"Invalid weighted pick for {prototype.ID}!");
}
public static string Pick(this IRobustRandom random, Dictionary<string, float> weights)
public static T Pick<T>(this IRobustRandom random, Dictionary<T, float> weights)
where T: notnull
{
var sum = weights.Values.Sum();
var accumulated = 0f;
@@ -74,7 +75,7 @@ namespace Content.Shared.Random.Helpers
}
}
throw new InvalidOperationException($"Invalid weighted pick");
throw new InvalidOperationException("Invalid weighted pick");
}
public static (string reagent, FixedPoint2 quantity) Pick(this WeightedRandomFillSolutionPrototype prototype, IRobustRandom? random = null)