public static void setPlayerUnitSettings(PlayerUnitSettings playerUnitSettings, APlayableEntity entity, IUnitSettingCollectionItem[] collection)
 {
     if (playerUnitSettings != null)
     {
         foreach (IUnitSettingCollectionItem item in collection)
         {
             UnitPreference.setPreference(entity, item.Name, playerUnitSettings.getSetting(item).Enabled);
         }
     }
 }
 public static void updatePlayerUnitSettings(ref PlayerUnitSettings playerUnitSettings, APlayableEntity entity, IUnitSettingCollectionItem[] collection)
 {
     if (UnitPreference.isPlayableEntity(entity))
     {
         playerUnitSettings = PlayerUnitSettings.fromEntity(entity, collection);
     }
     else
     {
         playerUnitSettings = null;
     }
 }
        public static PlayerUnitSettings fromEntity(APlayableEntity entity, IUnitSettingCollectionItem[] collection)
        {
            List<UnitSetting> tempSettings = new List<UnitSetting>();
            UnitSetting tempSetting;
            foreach (IUnitSettingCollectionItem item in collection)
            {
                tempSetting = new UnitSetting();
                tempSetting.Item = item;
                tempSetting.Enabled = UnitPreference.getPreference(entity, item.Name);

                tempSettings.Add(tempSetting);
            }

            PlayerUnitSettings playerUnitSettings = new PlayerUnitSettings();
            playerUnitSettings.UnitSettings = tempSettings;

            return playerUnitSettings;
        }