public static bool DetectIfPairedMeme(ref List <MemeDef> ___newMemes)

        {
            for (int i = 0; i < ___newMemes.Count; i++)
            {
                ExtendedMemeProperties extendedMemeProps = ___newMemes[i].GetModExtension <ExtendedMemeProperties>();
                if (extendedMemeProps != null && extendedMemeProps.requiredMemes != null)
                {
                    bool          flagAnyFound  = false;
                    List <string> memeNamesList = new List <string>();
                    foreach (string requiredMeme in extendedMemeProps.requiredMemes)
                    {
                        MemeDef meme = DefDatabase <MemeDef> .GetNamedSilentFail(requiredMeme);

                        if (meme != null)
                        {
                            memeNamesList.Add(meme.LabelCap);
                            if (___newMemes.Contains(meme))
                            {
                                flagAnyFound = true;
                            }
                        }
                    }
                    if (!flagAnyFound)
                    {
                        string memeNames = string.Join(", ", memeNamesList);
                        Messages.Message("VME_MessageNeedsThePairedMeme".Translate(___newMemes[i].label, memeNames), MessageTypeDefOf.RejectInput, false);
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#2
0
        private bool doConvert()
        {
            Faction faction;

            if (!this.TryFindConvertFaction(out faction))
            {
                return(false);
            }

            // adopt similar ideology from ally
            List <MemeDef> initialmemes = faction.ideos.PrimaryIdeo.memes;

            for (int i = 0; i < initialmemes.Count; i++)
            {
                MemeDef eachmeme = initialmemes[i];
                if (eachmeme.impact >= 2)
                {
                    List <Ideo> worldIdeo = Find.IdeoManager.IdeosListForReading;
                    for (int y = 0; y < worldIdeo.Count; y++)
                    {
                        Ideo eachIdeo = worldIdeo[y];
                        if (eachIdeo.HasMeme(eachmeme) && eachIdeo != faction.ideos.PrimaryIdeo)
                        {
                            List <Faction> proselytizer = (from x in Find.FactionManager.AllFactionsVisible
                                                           where !x.def.hidden && (!x.IsPlayer || faction.RelationKindWith(Faction.OfPlayer) == FactionRelationKind.Ally) && !x.defeated && x != faction && !x.HostileTo(faction) && x.ideos.PrimaryIdeo == eachIdeo
                                                           select x).ToList <Faction>();

                            for (int x = 0; x < proselytizer.Count; x++)
                            {
                                Faction temp        = proselytizer[x];
                                int     randomIndex = Random.Range(x, proselytizer.Count);
                                proselytizer[x]           = proselytizer[randomIndex];
                                proselytizer[randomIndex] = temp;
                            }

                            if (proselytizer.Count > 0)
                            {
                                faction.ideos.SetPrimary(eachIdeo);
                                Find.IdeoManager.RemoveUnusedStartingIdeos();
                                faction.leader.ideo.SetIdeo(eachIdeo);
                                Find.LetterStack.ReceiveLetter("LabelDDProselytization".Translate(), "DescDDProselytization".Translate(faction.Name, eachIdeo.name, proselytizer.RandomElement <Faction>().Name, eachmeme.label), LetterDefOf.NeutralEvent);
                                return(true);
                            }
                        }
                    }
                }
            }

            // adopt new ideology with FactionDef limitations
            Ideo           newIdeo          = IdeoGenerator.GenerateIdeo(FactionIdeosTracker.IdeoGenerationParmsForFaction_BackCompatibility(faction.def));
            List <Faction> sameideofactions = (from x in Find.FactionManager.AllFactionsVisible
                                               where !x.def.hidden && !x.defeated && x != faction && x.ideos.PrimaryIdeo == faction.ideos.PrimaryIdeo
                                               select x).ToList <Faction>();

            faction.ideos.SetPrimary(newIdeo);
            Find.IdeoManager.Add(newIdeo);
            faction.leader.ideo.SetIdeo(newIdeo);
            Find.IdeoManager.RemoveUnusedStartingIdeos();
            if (sameideofactions.Count > 0)
            {
                Find.LetterStack.ReceiveLetter("LabelDDFoundation".Translate(), "DescDDFoundation".Translate(faction.Name, newIdeo.name), LetterDefOf.NeutralEvent);
            }

            return(true);
        }