Unify junction props

This commit is contained in:
2026-05-10 18:05:32 +02:00
parent 1aa9734e08
commit 9cd9defc0b
13 changed files with 70 additions and 84 deletions

View File

@@ -17,9 +17,7 @@ public sealed record JunctionFlow
if (index < 0)
return 0;
var weights = Prop.Type == EPropType.TJunction
? TJunctionWeights(Prop.TJunctionMode)
: CrossJunctionWeights(Prop.CrossJunctionMode);
var weights = Balancing.Current.JunctionWeights(OutgoingBranches.Count, Prop.JunctionMode);
return index < weights.Length ? weights[index] : 0;
}
@@ -33,27 +31,4 @@ public sealed record JunctionFlow
return -1;
}
private static float[] TJunctionWeights(ETJunctionMode mode)
{
return mode switch {
ETJunctionMode.ZeroFour => [0, 1],
ETJunctionMode.OneThree => [0.25f, 0.75f],
ETJunctionMode.TwoTwo => [0.5f, 0.5f],
ETJunctionMode.ThreeOne => [0.75f, 0.25f],
ETJunctionMode.FourZero => [1, 0],
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, "Unsupported T-junction mode.")
};
}
private static float[] CrossJunctionWeights(ECrossJunctionMode mode)
{
return mode switch {
ECrossJunctionMode.ZeroThreeThree => [0, 0.5f, 0.5f],
ECrossJunctionMode.ThreeZeroThree => [0.5f, 0, 0.5f],
ECrossJunctionMode.ThreeThreeZero => [0.5f, 0.5f, 0],
ECrossJunctionMode.TwoTwoTwo => [1f / 3f, 1f / 3f, 1f / 3f],
_ => throw new ArgumentOutOfRangeException(nameof(mode), mode, "Unsupported cross-junction mode.")
};
}
}
}