fix a station event weighting bug (#33584)

* fractional weights dont work in StationEvents

* force-int

* sure why not, we can keep floats I guess.
This commit is contained in:
IProduceWidgets
2024-12-05 23:52:02 -05:00
committed by GitHub
parent 0e6ec2e1af
commit 3e0b93d071

View File

@@ -148,20 +148,20 @@ public sealed class EventManagerSystem : EntitySystem
return null;
}
var sumOfWeights = 0;
var sumOfWeights = 0.0f;
foreach (var stationEvent in availableEvents.Values)
{
sumOfWeights += (int) stationEvent.Weight;
sumOfWeights += stationEvent.Weight;
}
sumOfWeights = _random.Next(sumOfWeights);
sumOfWeights = _random.NextFloat(sumOfWeights);
foreach (var (proto, stationEvent) in availableEvents)
{
sumOfWeights -= (int) stationEvent.Weight;
sumOfWeights -= stationEvent.Weight;
if (sumOfWeights <= 0)
if (sumOfWeights <= 0.0f)
{
return proto.ID;
}