コード例 #1
0
ファイル: NeedsUtility.cs プロジェクト: kfish610/Nutrition
 public static T As <T>(this Need_FoodGroup foodGroupNeed) where T : Need_FoodGroup
 {
     if (foodGroupNeed is T foodGroup)
     {
         return(foodGroup);
     }
     return(null);
 }
コード例 #2
0
ファイル: NeedsUtility.cs プロジェクト: kfish610/Nutrition
 public static SpecialThingFilterDef GetFilter(this Need_FoodGroup foodGroupNeed)
 {
     if (foodGroupNeed is Need_Vegetables)
     {
         return(SpecialThingFilterDef.Named("AllowVegetables"));
     }
     if (foodGroupNeed is Need_Fruit)
     {
         return(SpecialThingFilterDef.Named("AllowFruit"));
     }
     if (foodGroupNeed is Need_Grain)
     {
         return(SpecialThingFilterDef.Named("AllowGrain"));
     }
     if (foodGroupNeed is Need_Protein)
     {
         return(SpecialThingFilterDef.Named("AllowProtein"));
     }
     if (foodGroupNeed is Need_Dairy)
     {
         return(SpecialThingFilterDef.Named("AllowDairy"));
     }
     throw new NotImplementedException();
 }