Пример #1
0
        public T Load <T>(IAssetInfo asset)
        {
            foreach (var farmAnimalType in FarmAnimals.GetCategories()
                     .SelectMany(
                         o => (IEnumerable <FarmAnimalType>)o.Types))
            {
                if (farmAnimalType.HasAdultSprite() &&
                    asset.AssetNameEquals(FarmAnimal.BuildSpriteAssetName(farmAnimalType.Type)))
                {
                    return((T)(object)Mod.LoadTexture(farmAnimalType.Sprites.Adult));
                }
                if (farmAnimalType.HasBabySprite() &&
                    asset.AssetNameEquals(FarmAnimal.BuildSpriteAssetName(farmAnimalType.Type, true)))
                {
                    return((T)(object)Mod.LoadTexture(farmAnimalType.Sprites.Baby));
                }
                if (farmAnimalType.HasReadyForHarvestSprite() &&
                    asset.AssetNameEquals(FarmAnimal.BuildSpriteAssetName(farmAnimalType.Type, isSheared: true)))
                {
                    return((T)(object)Mod.LoadTexture(farmAnimalType.Sprites.ReadyForHarvest));
                }
            }

            throw new InvalidOperationException("Unexpected asset '" + asset.AssetName + "'.");
        }
Пример #2
0
 public bool CanLoad <T>(IAssetInfo asset)
 {
     foreach (var farmAnimalType in FarmAnimals.GetCategories().SelectMany(o => (IEnumerable <FarmAnimalType>)o.Types))
     {
         if (farmAnimalType.HasAdultSprite() &&
             asset.AssetNameEquals(FarmAnimal.BuildSpriteAssetName(farmAnimalType.Type)) ||
             farmAnimalType.HasBabySprite() &&
             asset.AssetNameEquals(FarmAnimal.BuildSpriteAssetName(farmAnimalType.Type, true)) ||
             farmAnimalType.HasReadyForHarvestSprite() &&
             asset.AssetNameEquals(FarmAnimal.BuildSpriteAssetName(farmAnimalType.Type, isSheared: true)))
         {
             return(true);
         }
     }
     return(false);
 }