Reduce some state handling allocs (#14301)

This commit is contained in:
metalgearsloth
2023-03-01 03:05:29 +11:00
committed by GitHub
parent 644e2e2d60
commit b9a805b352
4 changed files with 30 additions and 8 deletions

View File

@@ -104,7 +104,12 @@ public partial class MobStateSystem : EntitySystem
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)