public virtual void DoFailActions()
        {
            if (this.mageList != null && this.mageList.Count > 0 && this.magicRecipeDef != null)
            {
                foreach (var mage in mageList)
                {
                    TM_Action.ConsumeManaXP(mage, this.magicRecipeDef.manaCost / this.mageList.Count * (this.magicRecipeDef.failManaConsumed * (1f - ManaCostModifer)), .75f, true);
                    if (this.magicRecipeDef.failDamageApplied != 0)
                    {
                        TM_Action.DamageEntities(mage, null, Rand.Range(this.magicRecipeDef.failDamageApplied * .75f, this.magicRecipeDef.failDamageApplied * 1.25f), TMDamageDefOf.DamageDefOf.TM_Arcane, mage);
                    }
                }
            }
            string letterLabel = "LetterLabelRitualFail".Translate();

            if (this.magicRecipeDef.failDamageApplied > 0)
            {
                Find.LetterStack.ReceiveLetter(letterLabel, "LetterRitualFailDamage".Translate(this.magicRecipeDef.label, (1f - this.magicRecipeDef.failChance) * 100, this.magicRecipeDef.failDamageApplied), LetterDefOf.NegativeEvent);
            }
            else
            {
                Find.LetterStack.ReceiveLetter(letterLabel, "LetterRitualFail".Translate(this.magicRecipeDef.label, (1f - this.magicRecipeDef.failChance) * 100f), LetterDefOf.NegativeEvent);
            }
        }
        public virtual void DoSuccessActions()
        {
            if (this.mageList != null && this.mageList.Count > 0 && this.magicRecipeDef != null)
            {
                foreach (var mage in this.mageList)
                {
                    TM_Action.ConsumeManaXP(mage, this.magicRecipeDef.manaCost / this.mageList.Count * (1f - ManaCostModifer), 1f + ManaCostModifer, true);
                }

                if (this.magicRecipeDef.resultMapComponentConditions != null && this.magicRecipeDef.resultMapComponentConditions.Count > 0)
                {
                    for (int i = 0; i < this.magicRecipeDef.resultMapComponentConditions.Count; i++)
                    {
                        MagicMapComponent mmc = this.Map.GetComponent <MagicMapComponent>();
                        if (mmc != null)
                        {
                            mmc.ApplyComponentConditions(this.magicRecipeDef.resultMapComponentConditions[i]);
                        }
                    }
                }
                if (this.magicRecipeDef.resultConditions != null && this.magicRecipeDef.resultConditions.Count > 0)
                {
                    for (int i = 0; i < this.magicRecipeDef.resultConditions.Count; i++)
                    {
                        TMDefs.TM_Condition con = this.magicRecipeDef.resultConditions[i];
                        if (con.resultCondition != null || con.conditionRandom)
                        {
                            int range = con.countRange.RandomInRange;
                            for (int j = 0; j < range; j++)
                            {
                                TryGenerateMapCondition(con.resultCondition, this.Map, Mathf.RoundToInt(con.conditionDuration * (1 + DurationModifier)), con.conditionPermanent, con.conditionRemove, con.conditionAdd, con.conditionReduceByDuration, con.conditionIncreaseByDuration, con.conditionRandom);
                            }
                        }
                        if (con.resultWeather != null)
                        {
                            TryGenerateWeatherEvent(con.resultWeather, this.Map);
                        }
                    }
                }
                if (this.magicRecipeDef.resultIncidents != null && this.magicRecipeDef.resultIncidents.Count > 0)
                {
                    int incidentCount;
                    if (this.magicRecipeDef.selectRandomIncident)
                    {
                        incidentCount = this.magicRecipeDef.selectRandomIncidentCount;
                    }
                    else
                    {
                        incidentCount = this.magicRecipeDef.resultIncidents.Count;
                    }
                    for (int i = 0; i < incidentCount; i++)
                    {
                        TMDefs.TM_Incident inc = this.magicRecipeDef.resultIncidents[i];
                        if (this.magicRecipeDef.selectRandomIncident)
                        {
                            inc = this.magicRecipeDef.resultIncidents[Rand.RangeInclusive(0, this.magicRecipeDef.resultIncidents.Count - 1)];
                        }
                        if (inc.resultIncident != null)
                        {
                            int range = inc.countRange.RandomInRange;
                            for (int j = 0; j < range; j++)
                            {
                                TryGenerateIncident(inc.resultIncident, this.Map, Mathf.RoundToInt(inc.incidentPoints * (1f + PointModifer)), inc.incidentHostile);
                            }
                        }
                    }
                }
                if (this.magicRecipeDef.resultHediffs != null && this.magicRecipeDef.resultHediffs.Count > 0)
                {
                    for (int i = 0; i < this.magicRecipeDef.resultHediffs.Count; i++)
                    {
                        TMDefs.TM_Hediff hd = this.magicRecipeDef.resultHediffs[i];
                        if (hd.resultHediff != null)
                        {
                            int range = hd.countRange.RandomInRange;
                            for (int j = 0; j < range; j++)
                            {
                                TryApplyHediff(hd.resultHediff, this.Faction, this.Map, this.MageList.First(), hd.hediffSeverity * (1f + DurationModifier), Mathf.RoundToInt(hd.maxHediffCount * (1f + PointModifer)), hd.checkResistance, hd.applyFriendly, hd.applyEnemy, hd.applyNeutral, hd.applyNullFaction, hd.moteDef);
                            }
                        }
                    }
                }
                if (this.magicRecipeDef.resultSpawnThings != null && this.magicRecipeDef.resultSpawnThings.Count > 0)
                {
                    for (int i = 0; i < this.magicRecipeDef.resultSpawnThings.Count; i++)
                    {
                        TMDefs.TM_SpawnThings st = this.magicRecipeDef.resultSpawnThings[i];
                        if (st.resultSpawnThing != null)
                        {
                            int range = st.countRange.RandomInRange;
                            for (int j = 0; j < range; j++)
                            {
                                IntVec3 spawnPos = GetCircleCenter;
                                spawnPos.x += Rand.Range(-(range - 1), range - 1);
                                spawnPos.z += Rand.Range(-(range - 1), range - 1);
                                TrySpawnThing(this.MageList.RandomElement(), st.resultSpawnThing, st.resultPawnKindDef, spawnPos, Mathf.RoundToInt(st.summonDuration * (1f + DurationModifier)), st.summonTemporary, Mathf.RoundToInt(st.spawnThingCount * (1f + PointModifer)), Mathf.RoundToInt(st.spawnThingStackCount * (1f + PointModifer)), st.spawnHostile);
                            }
                        }
                    }
                }
            }
        }