Skip to content

Commit

Permalink
Make description of cactus plant contain both produced items
Browse files Browse the repository at this point in the history
  • Loading branch information
daviscook477 committed Jan 9, 2020
1 parent 140a244 commit c83ab6f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/RollerSnake/CactusFruitPatches.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System.Collections.Generic;
using TUNING;
using Harmony;
using STRINGS;
Expand Down Expand Up @@ -95,5 +96,35 @@ public static void Postfix(Crop __instance)
__instance.Trigger(-1072826864, null);
}
}

[HarmonyPatch(typeof(Crop), "InformationDescriptors")]
public class Crop_InformationDescriptors_Patch
{
public static void Postfix(Crop __instance, List<Descriptor> __result, GameObject go)
{
if (__instance == null)
return;
Crop.CropVal cropVal = __instance.cropVal;
if (string.IsNullOrEmpty(cropVal.cropId))
return;
if (cropVal.cropId != CactusFleshConfig.Id)
return;
Tag tag = new Tag(CactusFlowerConfig.Id);
GameObject prefab = Assets.GetPrefab(tag);
Edible component1 = prefab.GetComponent<Edible>();
float calories1 = 0.0f;
string str1 = string.Empty;
if (component1 != null)
calories1 = component1.FoodInfo.CaloriesPerUnit;
float calories2 = calories1 * 1.0f;
InfoDescription component2 = prefab.GetComponent<InfoDescription>();
if ((bool)(component2))
str1 = component2.description;
string str2 = !GameTags.DisplayAsCalories.Contains(tag) ? (!GameTags.DisplayAsUnits.Contains(tag) ? GameUtil.GetFormattedMass(1.0f, GameUtil.TimeSlice.None, GameUtil.MetricMassFormat.UseThreshold, true, "{0:0.#}") : GameUtil.GetFormattedUnits(1.0f, GameUtil.TimeSlice.None, false)) : GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true);
Descriptor descriptor1 = new Descriptor(string.Format((string)UI.UISIDESCREENS.PLANTERSIDESCREEN.YIELD, (object)prefab.GetProperName(), (object)str2), string.Format((string)UI.UISIDESCREENS.PLANTERSIDESCREEN.TOOLTIPS.YIELD, (object)str1, (object)GameUtil.GetFormattedCalories(calories1, GameUtil.TimeSlice.None, true), (object)GameUtil.GetFormattedCalories(calories2, GameUtil.TimeSlice.None, true)), Descriptor.DescriptorType.Effect, false);
__result.Add(descriptor1);
}
}

}
}

0 comments on commit c83ab6f

Please sign in to comment.