public FailTracker(FailConditions settings, bool reloading = false)
 {
     this.settings = settings;
     if (!reloading)
     {
         foreach (ThingValue tv in settings.targetSettings.targets)
         {
             TargetsLost.Add(tv, 0);
         }
     }
 }
        private float ContentHeight()
        {
            float value = 0f;
            List <FailConditions> cond = new List <FailConditions>();

            if (selectedMission?.def.failConditions != null)
            {
                value += Text.CalcHeight("Mission_SMO".Translate() + ": " + selectedMission.def.LabelCap, 196f) + 2f;
                if (selectedMission.LatestState == MOState.Active)
                {
                    cond.Add(selectedMission?.def.failConditions);
                }
            }
            if (selectedObjective?.def.failConditions != null)
            {
                value += Text.CalcHeight("Objective_SMO".Translate() + ": " + selectedObjective.def.LabelCap, 196f) + 2f;
                if (selectedObjective.CurrentState == MOState.Active)
                {
                    cond.Add(selectedObjective.def.failConditions);
                }
            }
            for (int i = 0; i < cond.Count; i++)
            {
                FailConditions condition    = cond[i];
                bool           whenFinished = condition.whenFinished;
                if (!condition.objectives.NullOrEmpty())
                {
                    string objectives = whenFinished ? "FailCon_ObjectiveDone".Translate() : "FailCon_ObjectiveFail".Translate();
                    value += Text.CalcHeight(objectives + ":", 196f - 9f);
                    value += (condition.objectives.Count * 12f) + 2f;
                }
                if (!condition.missions.NullOrEmpty())
                {
                    string missions = whenFinished ? "FailCon_MissionDone".Translate() : "FailCon_MissionFail".Translate();
                    value += Text.CalcHeight(missions + ":", 196f - 9f);
                    value += (condition.missions.Count * 12f) + 2f;
                }
                if ((condition.targetSettings?.targets.Count ?? 0) > 0)
                {
                    string targets = condition.targetSettings.any ? "FailCon_TargetsAny".Translate() : "FailCon_Targets".Translate();
                    value += Text.CalcHeight(targets + ":", 196f - 9f);
                    value += (condition.targetSettings.targets.Count) * 12f + 2f;
                }
                if (condition.targetSettings?.minColonistsToLose > 0)
                {
                    value += 12f + 2f;
                }
            }
            return(value);
        }
        private void FailconReadout <T>(T t, FailConditions conditions, ref Listing_Standard listing)
        {
            FailTracker failTracker  = t is Mission ? (t as Mission).failTracker : (t as Objective).failTracker;
            bool        whenFinished = conditions.whenFinished;

            if (!conditions.missions.NullOrEmpty())
            {
                string missions = whenFinished ? "FailCon_MissionDone".Translate() : "FailCon_MissionFail".Translate();
                listing.IconLabel(StoryMats.warning, (missions + ":"), new Vector2(9f, 18f));
                foreach (MissionDef mdef in conditions.missions)
                {
                    listing.Label("    - " + mdef.LabelCap);
                }
            }
            if (!conditions.objectives.NullOrEmpty())
            {
                string objectives = whenFinished ? "FailCon_ObjectiveDone".Translate() : "FailCon_ObjectiveFail".Translate();
                listing.IconLabel(StoryMats.warning, (objectives + ":"), new Vector2(9f, 18f));
                foreach (ObjectiveDef oDef in conditions.objectives)
                {
                    listing.Label("    - " + oDef.LabelCap);
                }
            }
            if (!conditions.targetSettings.targets.NullOrEmpty())
            {
                string targets = conditions.targetSettings.any ? "FailCon_TargetsAny".Translate() : "FailCon_Targets".Translate();
                listing.IconLabel(StoryMats.warning, (targets + ":"), new Vector2(9f, 18f));
                foreach (ThingValue tv in conditions.targetSettings.targets)
                {
                    listing.Label("    - " + tv.ThingDef.LabelCap + " - " + failTracker.TargetsLost[tv] + "/" + tv.value);
                }
            }
            if (conditions.targetSettings.minColonistsToLose > 0)
            {
                listing.IconLabel(StoryMats.warning, "FailCon_DeadColonists".Translate() + ": " + failTracker.lostColonists + "/" + conditions.targetSettings.minColonistsToLose, new Vector2(9f, 18f));
            }
        }