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:
@@ -148,20 +148,20 @@ public sealed class EventManagerSystem : EntitySystem
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sumOfWeights = 0;
|
var sumOfWeights = 0.0f;
|
||||||
|
|
||||||
foreach (var stationEvent in availableEvents.Values)
|
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)
|
foreach (var (proto, stationEvent) in availableEvents)
|
||||||
{
|
{
|
||||||
sumOfWeights -= (int) stationEvent.Weight;
|
sumOfWeights -= stationEvent.Weight;
|
||||||
|
|
||||||
if (sumOfWeights <= 0)
|
if (sumOfWeights <= 0.0f)
|
||||||
{
|
{
|
||||||
return proto.ID;
|
return proto.ID;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user