Sakuno.KanColle.Amatsukaze.Game.AirBase.UpdateGroups C# (CSharp) Method

UpdateGroups() private method

private UpdateGroups ( RawAirForceGroup rpGroups ) : void
rpGroups Sakuno.KanColle.Amatsukaze.Game.Models.Raw.RawAirForceGroup
return void
        internal void UpdateGroups(RawAirForceGroup[] rpGroups)
        {
            if (rpGroups == null)
                return;

            HashSet<int> rRemovedIDs = null;
            if (Table.Count > 0)
                rRemovedIDs = new HashSet<int>(Table.Keys);

            var rUpdate = false;

            var rAreas = rpGroups.GroupBy(r => r.AreaID);
            foreach (var rArea in rAreas)
            {
                var rAreaID = rArea.Key;

                IDTable<AirForceGroup> rGroups;
                if (!Table.TryGetValue(rAreaID, out rGroups))
                    Table.Add(rAreaID, rGroups = new IDTable<AirForceGroup>());

                rUpdate |= rGroups.UpdateRawData(rArea, r => new AirForceGroup(r), (rpData, rpRawData) => rpData.Update(rpRawData));

                if (rRemovedIDs != null)
                    rRemovedIDs.Remove(rAreaID);
            }

            if (rRemovedIDs != null)
                foreach (var rID in rRemovedIDs)
                {
                    Table.Remove(rID);
                    rUpdate = true;
                }

            if (rUpdate)
                OnPropertyChanged(nameof(AllGroups));
        }
    }