Reduce some state handling allocs (#14301)
This commit is contained in:
@@ -340,7 +340,17 @@ public sealed class MobThresholdSystem : EntitySystem
|
||||
if (args.Current is not MobThresholdComponentState state)
|
||||
return;
|
||||
|
||||
component.Thresholds = new SortedDictionary<FixedPoint2, MobState>(state.Thresholds);
|
||||
if (component.Thresholds.Count != state.Thresholds.Count ||
|
||||
!component.Thresholds.SequenceEqual(state.Thresholds))
|
||||
{
|
||||
component.Thresholds.Clear();
|
||||
|
||||
foreach (var threshold in state.Thresholds)
|
||||
{
|
||||
component.Thresholds.Add(threshold.Key, threshold.Value);
|
||||
}
|
||||
}
|
||||
|
||||
component.CurrentThresholdState = state.CurrentThresholdState;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user