public static void SetActiveTargetingGroups(List <TargetingGroup> newTGs) { // check for newly added TGs foreach (TargetingGroup newTG in newTGs) { if (!activeTargetingGroups.Contains(newTG)) { // if this TG is newly added, alert all MTs which belong to it foreach (MouseTargetable MT in allMouseTargetables) { if (MT.targetingGroup == newTG) { MT.OnTGNewlyAdded(); } } } } // check for newly removed TGs foreach (TargetingGroup oldTG in activeTargetingGroups) { if (!newTGs.Contains(oldTG)) { // if this TG has just been removed, alert all MTs which belong to it foreach (MouseTargetable MT in allMouseTargetables) { if (MT.targetingGroup == oldTG) { MT.OnTGNewlyRemoved(); } } } } // update TGs activeTargetingGroups = newTGs; }