Ejemplo n.º 1
0
 static void ForceTrait(Ideo ideo, Pawn ___pawn)
 {
     if (ideo != null)
     {
         foreach (MemeDef meme in ideo.memes)
         {
             ExtendedMemeProperties extendedMemeProps = meme.GetModExtension <ExtendedMemeProperties>();
             if (extendedMemeProps != null)
             {
                 if (extendedMemeProps.forcedTrait != null)
                 {
                     Trait trait = new Trait(extendedMemeProps.forcedTrait, 0, true);
                     ___pawn.story?.traits?.GainTrait(trait);
                 }
                 if (extendedMemeProps.abilitiesGiven != null)
                 {
                     foreach (AbilityDef ability in extendedMemeProps.abilitiesGiven)
                     {
                         ___pawn.abilities?.GainAbility(ability);
                     }
                 }
             }
         }
     }
 }
        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);
        }
Ejemplo n.º 3
0
        public override void FinalizeInit()
        {
            base.FinalizeInit();
            if (!Current.Game.GetComponent <GameComponent_IdeologicalGoodies>().sentOncePerGame)
            {
                List <Thing> things = new List <Thing>();

                foreach (StartingItemsByIdeologyDef startingItems in DefDatabase <StartingItemsByIdeologyDef> .AllDefsListForReading)
                {
                    if (Current.Game.World.factionManager.OfPlayer.ideos.PrimaryIdeo.HasMeme(startingItems.associatedMeme))
                    {
                        things.AddRange(startingItems.thingSetMaker.root.Generate());
                    }
                }
                if (things.Count > 0)
                {
                    DropPodUtility.DropThingsNear(MapGenerator.PlayerStartSpot, map, things, 110);
                }

                foreach (MemeDef meme in Current.Game.World.factionManager.OfPlayer.ideos.PrimaryIdeo.memes)
                {
                    ExtendedMemeProperties extendedMemeProperties = meme.GetModExtension <ExtendedMemeProperties>();
                    if (extendedMemeProperties != null)
                    {
                        if (extendedMemeProperties.factionOpinionOffset != 0)
                        {
                            var factions = Find.FactionManager.AllFactions;
                            foreach (var faction in factions)
                            {
                                faction.TryAffectGoodwillWith(Faction.OfPlayer, extendedMemeProperties.factionOpinionOffset, true, true);
                            }
                        }
                    }
                }



                Current.Game.GetComponent <GameComponent_IdeologicalGoodies>().sentOncePerGame = true;
            }
        }
        public static void DetectIfRequiredMeme(ref List <MemeDef> ___newMemes, ref Pair <MemeDef, MemeDef> __result)

        {
            List <MemeDef> memesTemp = ___newMemes;

            for (int i = 0; i < ___newMemes.Count; i++)
            {
                ExtendedMemeProperties extendedMemeProps = ___newMemes[i].GetModExtension <ExtendedMemeProperties>();
                if (extendedMemeProps != null && extendedMemeProps.neededMeme != null)
                {
                    List <MemeDef> structureMemeDefs = (from k in DefDatabase <MemeDef> .AllDefsListForReading
                                                        where k.category == MemeCategory.Structure && memesTemp.Contains(k)
                                                        select k).ToList();

                    foreach (MemeDef memeDef in structureMemeDefs)
                    {
                        if (___newMemes[i].GetModExtension <ExtendedMemeProperties>().neededMeme != memeDef.defName)
                        {
                            __result = new Pair <MemeDef, MemeDef>(___newMemes[i], memeDef);
                        }
                    }
                }
            }
        }