using System; using System.Collections.Generic; namespace RoR2; public class CatalogModHelper { private readonly Action registrationDelegate; private readonly Func nameGetter; public event Action> getAdditionalEntries; public CatalogModHelper(Action registrationDelegate, Func nameGetter) { this.registrationDelegate = registrationDelegate; this.nameGetter = nameGetter; } public void CollectAndRegisterAdditionalEntries(ref TEntry[] entries) { int num = entries.Length; List list = new List(); this.getAdditionalEntries?.Invoke(list); list.Sort((TEntry a, TEntry b) => StringComparer.Ordinal.Compare(nameGetter(a), nameGetter(b))); Array.Resize(ref entries, entries.Length + list.Count); int i = 0; for (int count = list.Count; i < count; i++) { entries[num + i] = list[i]; registrationDelegate?.Invoke(num + i, list[i]); } } }