private void ShowEngeryWithoutUsing(bool succeed, ColonyAchievementRequirement req) { ProduceXEngeryWithoutUsingYList produceXEngeryWithoutUsingYList = req as ProduceXEngeryWithoutUsingYList; if (req != null) { HierarchyReferences nextRequirementWidget = GetNextRequirementWidget(); float productionAmount = produceXEngeryWithoutUsingYList.GetProductionAmount(succeed); SetDescription(string.Format(COLONY_ACHIEVEMENTS.MISC_REQUIREMENTS.STATUS.GENERATE_POWER, GameUtil.GetFormattedRoundedJoules(productionAmount), GameUtil.GetFormattedRoundedJoules(produceXEngeryWithoutUsingYList.amountToProduce * 1000f)), nextRequirementWidget); if (succeed) { SetIcon(statusSuccessIcon, Color.green, nextRequirementWidget); } else { ShowIcon(false, nextRequirementWidget); } foreach (Tag disallowedBuilding in produceXEngeryWithoutUsingYList.disallowedBuildings) { nextRequirementWidget = GetNextRequirementWidget(); if (Game.Instance.savedInfo.powerCreatedbyGeneratorType.ContainsKey(disallowedBuilding)) { SetIcon(statusFailureIcon, Color.red, nextRequirementWidget); } else { SetIcon(statusSuccessIcon, Color.green, nextRequirementWidget); } BuildingDef buildingDef = Assets.GetBuildingDef(disallowedBuilding.Name); SetDescription(string.Format(COLONY_ACHIEVEMENTS.MISC_REQUIREMENTS.STATUS.NO_BUILDING, buildingDef.Name), nextRequirementWidget); } } }
public static List <string> SuperSustainableFormatter(ColonyAchievementStatus cas) { List <string> outStrings = new List <string>(); ProduceXEngeryWithoutUsingYList __instance = (ProduceXEngeryWithoutUsingYList)cas.Requirements.Find(s => s is ProduceXEngeryWithoutUsingYList); var priv = Traverse.Create(__instance); List <Tag> disallowedBuildings = (List <Tag>)priv.Field("disallowedBuildings").GetValue(); bool mooted = (bool)priv.Field("usedDisallowedBuilding").GetValue(); float toMake = (float)priv.Field("amountToProduce").GetValue(); float num = 0.0f; foreach (KeyValuePair <Tag, float> keyValuePair in Game.Instance.savedInfo.powerCreatedbyGeneratorType) { if (!disallowedBuildings.Contains(keyValuePair.Key)) { num += keyValuePair.Value; } } double made = (double)num / 1000.0; string output = string.Format("Clean Energy Generated: {0} / {1}", made, toMake); outStrings.Add(output); return(outStrings); }
/// <summary> /// Applied before Success runs. /// </summary> internal static bool Prefix(ProduceXEngeryWithoutUsingYList __instance, ref bool __result) { float total = 0f; var disallow = HashSetPool <Tag, ProduceXEngeryWithoutUsingYList> .Allocate(); // Set is faster than a List here, as the test is expected to fail most times if // this achievement is still achievable foreach (var tag in __instance.disallowedBuildings) { disallow.Add(tag); } foreach (var pair in Game.Instance.savedInfo.powerCreatedbyGeneratorType) { if (!disallow.Contains(pair.Key)) { total += pair.Value; } } disallow.Recycle(); __result = total * 0.001f > __instance.amountToProduce; return(false); }