if (args.Current is not DoorComponentState state)
return;
- if (!door.CurrentlyCrushing.Equals(state.CurrentlyCrushing))
+ if (!door.CurrentlyCrushing.SetEquals(state.CurrentlyCrushing))
{
- door.CurrentlyCrushing = new(state.CurrentlyCrushing);
+ door.CurrentlyCrushing.Clear();
+ door.CurrentlyCrushing.UnionWith(state.CurrentlyCrushing);
}
door.State = state.DoorState;
return;
component.CurrentState = state.CurrentState;
- component.AllowedStates = new HashSet<MobState>(state.AllowedStates);
+
+ if (!component.AllowedStates.SetEquals(state.AllowedStates))
+ {
+ component.AllowedStates.Clear();
+ component.AllowedStates.UnionWith(state.AllowedStates);
+ }
}
private void OnGetComponentState(EntityUid uid, MobStateComponent component, ref ComponentGetState args)
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;
}
component.IntersectRatio = state.IntersectRatio;
component.Active = state.Active;
- component.CurrentlySteppedOn.Clear();
- component.Colliding.Clear();
+ if (!component.CurrentlySteppedOn.SetEquals(state.CurrentlySteppedOn))
+ {
+ component.CurrentlySteppedOn.Clear();
+ component.CurrentlySteppedOn.UnionWith(state.CurrentlySteppedOn);
+ }
- component.CurrentlySteppedOn.UnionWith(state.CurrentlySteppedOn);
- component.Colliding.UnionWith(state.Colliding);
+ if (!component.Colliding.SetEquals(state.Colliding))
+ {
+ component.Colliding.Clear();
+ component.Colliding.UnionWith(state.Colliding);
+ }
if (component.Colliding.Count > 0)
{