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 deltanedas
parent 7a24a09e8d
commit e41f317513
1 changed files with 5 additions and 5 deletions

View File

@ -152,20 +152,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;
}