Exemple #1
0
        public static void RestrictAnimals(ThingDef race, List <ThingDef> listWhite = null, List <ThingDef> listBlack = null, bool Logging = false)
        {
            AlienRace.ThingDef_AlienRace alien = race as AlienRace.ThingDef_AlienRace;
            if (alien == null)
            {
                return;
            }
            List <ThingDef> list      = alien.alienRace.raceRestriction.petList;
            List <ThingDef> whitelist = alien.alienRace.raceRestriction.whitePetList;
            List <ThingDef> blacklist = alien.alienRace.raceRestriction.blackPetList;

            RestrictThings(ref list, ref whitelist, ref blacklist, ref RaceRestrictionSettings.petRestricted, listWhite, listBlack, Logging);

            /*
             * alien.alienRace.raceRestriction.petList.AddRange(listWhite);
             * alien.alienRace.raceRestriction.whitePetList.AddRange(listWhite);
             * foreach (ThingDef def in listWhite)
             * {
             *  if (!RaceRestrictionSettings.petRestricted.Contains(def))
             *  {
             *      RaceRestrictionSettings.petRestricted.Add(def);
             *  }
             * }
             */
        }
            public ExposableValueTuple <Color, Color> GetChannel(string channel)
            {
                if (this.ColorChannels.ContainsKey(channel))
                {
                    return(this.ColorChannels[channel]);
                }

                ThingDef_AlienRace alienProps = ((ThingDef_AlienRace)this.parent.def);
                AlienPartGenerator apg        = alienProps.alienRace.generalSettings.alienPartGenerator;

                foreach (ColorChannelGenerator apgChannel in apg.colorChannels)
                {
                    if (apgChannel.name == channel)
                    {
                        this.ColorChannels.Add(channel, new ExposableValueTuple <Color, Color>());
                        if (apgChannel.first != null)
                        {
                            this.ColorChannels[channel].first = this.GenerateColor(apgChannel.first);
                        }
                        if (apgChannel.second != null)
                        {
                            this.ColorChannels[channel].second = this.GenerateColor(apgChannel.second);
                        }

                        return(this.ColorChannels[channel]);
                    }
                }

                return(new ExposableValueTuple <Color, Color>(Color.white, Color.white));
            }
Exemple #3
0
        public static Vector2 AlienRacesPatch(Pawn pawn, Thing eq)
        {
            AlienRace.ThingDef_AlienRace alienDef = pawn.def as AlienRace.ThingDef_AlienRace;
            Vector2 s;

            if (alienDef != null)
            {
                //	AlienRace.GraphicPaths paths = alienDef.alienRace.graphicPaths.GetCurrentGraphicPath(pawn.ageTracker.CurLifeStage);
                //	Log.Message(pawn.Name + " is Alien");
                s = alienDef.alienRace.generalSettings.alienPartGenerator.customDrawSize;
            }
            else
            {
                s = new Vector3(eq.def.graphicData.drawSize.x, 1f, eq.def.graphicData.drawSize.y);
            }
            return(s);
        }
Exemple #4
0
        public static void RestrictRecipes(ThingDef race, List <RecipeDef> listWhite, List <RecipeDef> listBlack = null, bool Logging = false)
        {
            AlienRace.ThingDef_AlienRace alien = race as AlienRace.ThingDef_AlienRace;
            if (alien == null)
            {
                return;
            }
            RestrictRecipes(ref alien.alienRace.raceRestriction.recipeList, ref alien.alienRace.raceRestriction.whiteRecipeList, ref alien.alienRace.raceRestriction.blackRecipeList, ref RaceRestrictionSettings.recipeRestricted, listWhite, listBlack, Logging);

            /*
             * alien.alienRace.raceRestriction.recipeList.AddRange(listWhite);
             * alien.alienRace.raceRestriction.whiteRecipeList.AddRange(listWhite);
             * foreach (RecipeDef def in listWhite)
             * {
             *  if (!RaceRestrictionSettings.recipeRestricted.Contains(def))
             *  {
             *      RaceRestrictionSettings.recipeRestricted.Add(def);
             *  }
             * }
             */
        }
Exemple #5
0
 public static void RestrictResearch(ThingDef race, List <ResearchProjectDef> listWhite = null, List <ResearchProjectDef> listBlack = null, bool Logging = false)
 {
     AlienRace.ThingDef_AlienRace alien = race as AlienRace.ThingDef_AlienRace;
     if (alien == null)
     {
         return;
     }
     if (alien.alienRace.raceRestriction.researchList.NullOrEmpty())
     {
         alien.alienRace.raceRestriction.researchList = new List <AlienRace.ResearchProjectRestrictions>();
         alien.alienRace.raceRestriction.researchList.Add(new AlienRace.ResearchProjectRestrictions());
         alien.alienRace.raceRestriction.researchList[0].projects    = new List <ResearchProjectDef>();
         alien.alienRace.raceRestriction.researchList[0].apparelList = new List <ThingDef>();
     }
     if (!listWhite.NullOrEmpty())
     {
         if (Logging)
         {
             debug.AppendLine("        Whitelising: " + listWhite.Count);
         }
         alien.alienRace.raceRestriction.researchList[0].projects.AddRange(listWhite);
         foreach (ResearchProjectDef def in listWhite)
         {
             if (Logging)
             {
                 debug.AppendLine("            " + def.defName);
             }
             if (!AlienRace.RaceRestrictionSettings.researchRestrictionDict.ContainsKey(key: def))
             {
                 List <AlienRace.ThingDef_AlienRace> l2 = new List <AlienRace.ThingDef_AlienRace>();
                 l2.Add(alien);
                 AlienRace.RaceRestrictionSettings.researchRestrictionDict.Add(key: def, value: l2);
             }
             else
             {
                 if (!AlienRace.RaceRestrictionSettings.researchRestrictionDict[key: def].Contains(alien))
                 {
                     AlienRace.RaceRestrictionSettings.researchRestrictionDict[key : def].Add(item : alien);
                 }
             }
         }
     }
     if (!listBlack.NullOrEmpty())
     {
         if (Logging)
         {
             debug.AppendLine("        blacklising: " + listBlack.Count);
         }
         //    alien.alienRace.raceRestriction.researchList[0].projects.AddRange(listBlack);
         foreach (ResearchProjectDef def in listBlack)
         {
             if (Logging)
             {
                 debug.AppendLine("            " + def.defName);
             }
             if (!AlienRace.RaceRestrictionSettings.researchRestrictionDict.ContainsKey(key: def))
             {
                 List <AlienRace.ThingDef_AlienRace> l2 = new List <AlienRace.ThingDef_AlienRace>();
                 l2.Add(alien);
                 AlienRace.RaceRestrictionSettings.researchRestrictionDict.Add(key: def, value: l2);
             }
             else
             {
                 if (!AlienRace.RaceRestrictionSettings.researchRestrictionDict[key: def].Contains(alien))
                 {
                     AlienRace.RaceRestrictionSettings.researchRestrictionDict[key : def].Add(item : alien);
                 }
             }
         }
     }
 }
Exemple #6
0
        public static void AlienRaces()
        {
            AlienRace.ThingDef_AlienRace Human = DefDatabase <ThingDef> .GetNamedSilentFail("Human") as AlienRace.ThingDef_AlienRace;

            if (Human != null)
            {
                List <string> Tags = new List <string>()
                {
                    "I", "C", "AS"
                };
                List <ResearchProjectDef> projects = new List <ResearchProjectDef>();
                projects.AddRange(ArmouryMain.ReseachImperial);
                projects.AddRange(ArmouryMain.ReseachChaos);
                //    DoRacialRestrictionsFor(Human, Tags, whiteResearches: projects);
            }
            AlienRace.ThingDef_AlienRace Mechanicus = ArmouryMain.mechanicus as AlienRace.ThingDef_AlienRace;
            AlienRace.ThingDef_AlienRace Ogryn      = ArmouryMain.ogryn as AlienRace.ThingDef_AlienRace;
            AlienRace.ThingDef_AlienRace Ratlin     = ArmouryMain.ratlin as AlienRace.ThingDef_AlienRace;
            AlienRace.ThingDef_AlienRace Beastman   = ArmouryMain.beastman as AlienRace.ThingDef_AlienRace;
            if (Mechanicus != null)
            {
                DoRacialRestrictionsFor(Mechanicus, "AM", whiteResearches: ArmouryMain.ReseachMechanicus, Logging: AMAMod.Dev);
            }
            List <ThingDef> races = new List <ThingDef>();

            if (Ogryn != null)
            {
                races.Add(Ogryn);
            }
            if (Ratlin != null)
            {
                races.Add(Ratlin);
            }
            if (Beastman != null)
            {
                races.Add(Beastman);
            }

            if (AdeptusIntergrationUtility.enabled_GeneSeed)
            {
                AlienRace.ThingDef_AlienRace GeneseedAstartes = ArmouryMain.geneseedAstartes as AlienRace.ThingDef_AlienRace;
                AlienRace.ThingDef_AlienRace GeneseedCustodes = ArmouryMain.geneseedCustodes as AlienRace.ThingDef_AlienRace;
                if (GeneseedAstartes != null)
                {
                    races.Add(GeneseedAstartes);
                }
                if (GeneseedCustodes != null)
                {
                    races.Add(GeneseedCustodes);
                }
            }
            if (AdeptusIntergrationUtility.enabled_AstraServoSkulls)
            {
                races.AddRange(DefDatabase <ThingDef> .AllDefsListForReading.Where(x => (x.defName.Contains("IG_Serv_ServoSkull") && x.defName.Contains("_Race")) || (x.defName.Contains("IG_Serv_Servitor") && x.defName.Contains("_Race"))));
            }

            if (!races.NullOrEmpty())
            {
                List <string> Tags = new List <string>()
                {
                    "I", "C"
                };
                List <ResearchProjectDef> projects = new List <ResearchProjectDef>();
                projects.AddRange(ArmouryMain.ReseachImperial);
                projects.AddRange(ArmouryMain.ReseachChaos);
                //    DoRacialRestrictionsFor(races, Tags, whiteResearches: projects);
            }
        }
Exemple #7
0
        public static void DoRacialRestrictionsFor(List <ThingDef> races, List <string> whiteTags, List <string> blackTags = null, List <ResearchProjectDef> whiteResearches = null, List <ResearchProjectDef> blackResearches = null, List <ThingDef> whiteApparel = null, List <ThingDef> blackApparel = null, List <ThingDef> whiteWeapons = null, List <ThingDef> blackWeapons = null, List <ThingDef> whitePlants = null, List <ThingDef> blackPlants = null, List <ThingDef> whiteAnimals = null, List <ThingDef> blackAnimals = null, bool Logging = false)
        {
            foreach (ThingDef race in races)
            {
                AlienRace.ThingDef_AlienRace alien = race as AlienRace.ThingDef_AlienRace;
                if (alien != null)
                {
                    debug = new StringBuilder("Try Do Racial Restrictions For " + alien.LabelCap + " (" + alien.defName + ")");
                    debug.AppendLine();
                    List <ThingDef>  blackBuildings = new List <ThingDef>();
                    List <ThingDef>  whiteBuildings = new List <ThingDef>();
                    List <RecipeDef> blackRecipes   = new List <RecipeDef>();
                    List <RecipeDef> whiteRecipes   = new List <RecipeDef>();
                    if (!whiteTags.NullOrEmpty())
                    {
                        foreach (string Tag in whiteTags)
                        {
                            List <RecipeDef> recipes = DefDatabase <RecipeDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("OG" + Tag + "_"));

                            if (!recipes.NullOrEmpty())
                            {
                                //    if (Logging) debug.AppendLine(recipes.Count + "   OG" + Tag + " whiteRecipes");
                                whiteRecipes.AddRange(recipes);
                            }
                            List <ThingDef> buildings = DefDatabase <ThingDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("OG" + Tag + "_") && (x.building != null || x.IsBuildingArtificial));

                            if (!buildings.NullOrEmpty())
                            {
                                //     if (Logging) debug.AppendLine(buildings.Count + "   OG" + Tag + " whiteBuildings");
                                whiteBuildings.AddRange(buildings);
                            }
                        }
                    }
                    if (!blackTags.NullOrEmpty())
                    {
                        foreach (string Tag in blackTags)
                        {
                            List <RecipeDef> recipes = DefDatabase <RecipeDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("OG" + Tag + "_"));

                            if (!recipes.NullOrEmpty())
                            {
                                //     if (Logging) debug.AppendLine(recipes.Count + "   OG" + Tag + " blackRecipes");
                                blackRecipes.AddRange(recipes);
                            }
                            List <ThingDef> buildings = DefDatabase <ThingDef> .AllDefsListForReading.FindAll(x => x.defName.Contains("OG" + Tag + "_") && (x.building != null || x.IsBuildingArtificial));

                            if (!buildings.NullOrEmpty())
                            {
                                //     if (Logging) debug.AppendLine(buildings.Count + "   OG" + Tag + " blackBuildings");
                                blackBuildings.AddRange(buildings);
                            }
                        }
                    }
                    if (!blackRecipes.NullOrEmpty() || !whiteRecipes.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Recipes: ");//+(blackRecipes.Count + whiteRecipes.Count));
                    }
                    RestrictRecipes(alien, whiteRecipes, blackRecipes, Logging);
                    if (!blackBuildings.NullOrEmpty() || !whiteBuildings.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Buildings: ");// + (blackBuildings.Count + whiteBuildings.Count));
                    }
                    RestrictBuildings(alien, whiteBuildings, blackBuildings, Logging);
                    if (!blackResearches.NullOrEmpty() || !whiteResearches.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Research: ");// + (blackResearches.Count + whiteResearches.Count));
                    }
                    RestrictResearch(alien, whiteResearches, blackResearches, Logging);
                    if (!blackApparel.NullOrEmpty() || !whiteApparel.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Apparel: ");// + (blackApparel.Count + whiteApparel.Count));
                    }
                    RestrictApparel(alien, whiteApparel, blackApparel, Logging);
                    if (!blackWeapons.NullOrEmpty() || !whiteWeapons.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Weapons: ");// + (blackWeapons.Count + whiteWeapons.Count));
                    }
                    RestrictWeapons(alien, whiteWeapons, blackWeapons, Logging);
                    if (!blackPlants.NullOrEmpty() || !whitePlants.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Plants: ");// + (blackPlants.Count + whitePlants.Count));
                    }
                    RestrictPlants(alien, whitePlants, blackPlants, Logging);
                    if (!blackAnimals.NullOrEmpty() || !whiteAnimals.NullOrEmpty() && Logging)
                    {
                        debug.AppendLine("    Animals: ");// + (blackAnimals.Count + whiteAnimals.Count));
                    }
                    RestrictAnimals(alien, whiteAnimals, blackAnimals, Logging);
                    if (Logging)
                    {
                        Log.Message(debug.ToString());
                    }
                }
            }
        }
Exemple #8
0
        private void TransformPawn(bool changeDef = true, bool keep = false)
        {
            //sets position, faction and map
            IntVec3 intv    = parent.pawn.Position;
            Faction faction = parent.pawn.Faction;
            Map     map     = parent.pawn.Map;

            RegionListersUpdater.DeregisterInRegions(parent.pawn, map);

            //Change Race to Props.raceDef
            var thingDef = Props.raceDef ?? null;

            if (changeDef && thingDef != null && thingDef != parent.pawn.def)
            {
                parent.pawn.def = thingDef;
                long ageB = Pawn.ageTracker.AgeBiologicalTicks;
                long ageC = Pawn.ageTracker.AgeChronologicalTicks;
                Pawn.ageTracker = new Pawn_AgeTracker(Pawn);
                Pawn.ageTracker.AgeBiologicalTicks    = ageB;
                Pawn.ageTracker.AgeChronologicalTicks = ageC;
                AlienRace.ThingDef_AlienRace           alienRace = (AlienRace.ThingDef_AlienRace)thingDef;
                AlienRace.AlienPartGenerator.AlienComp alien     = parent.pawn.TryGetComp <AlienRace.AlienPartGenerator.AlienComp>();

                if (Props.colourSkinTwo || Props.colourSkin)
                {
                    if (Props.colourSkin)
                    {
                        if (alien != null)
                        {
                            alien.skinColor = alienRace.alienRace.generalSettings.alienPartGenerator.SkinColor(parent.pawn);
                        }
                    }
                    if (Props.colourSkinTwo)
                    {
                        if (alien != null)
                        {
                            alien.skinColorSecond = alienRace.alienRace.generalSettings.alienPartGenerator.SkinColor(parent.pawn, false);
                        }
                    }
                    parent.pawn.Notify_ColorChanged();
                }
                if (Props.removeHair)
                {
                    parent.pawn.story.hairDef = PawnHairChooser.RandomHairDefFor(Pawn, noHairFaction);
                }
                else
                {
                    if (Props.colourHairTwo || Props.colourHair)
                    {
                        if (Props.colourHair)
                        {
                            if (alien != null)
                            {
                                Pawn.story.hairColor = alienRace.alienRace.generalSettings.alienPartGenerator.alienhaircolorgen.NewRandomizedColor();;
                            }
                        }
                        if (Props.colourHairTwo)
                        {
                            if (alien != null)
                            {
                                alien.hairColorSecond = alienRace.alienRace.generalSettings.alienPartGenerator.alienhaircolorgen.NewRandomizedColor();
                            }
                        }
                        parent.pawn.Notify_ColorChanged();
                    }
                }

                string head = alienRace.alienRace.graphicPaths.GetCurrentGraphicPath(Pawn.ageTracker.CurLifeStageRace.def).head;
                Traverse.Create(Pawn.story).Field("headGraphicPath").SetValue(alienRace.alienRace.generalSettings.alienPartGenerator.RandomAlienHead(head, Pawn));
            }
            //Remove Disallowed Traits
            int maxTraits;

            if (MoreTraitSlotsUtil.TryGetMaxTraitSlots(out int max))
            {
                maxTraits = max;
            }
            else
            {
                maxTraits = 4;
            }
            if (parent.pawn.story.traits.allTraits.Any(x => Props.traitsToRemove.Any(y => y.def == x.def)))
            {
                foreach (ExtendedTraitEntry item in Props.traitsToRemove)
                {
                    if (parent.pawn.story.traits.HasTrait(item.def))
                    {
                        Rand.PushState();
                        if (Rand.Chance(item.Chance))
                        {
                            parent.pawn.story.traits.allTraits.Remove(parent.pawn.story.traits.allTraits.Find(x => x.def == item.def));
                        }
                        Rand.PopState();
                    }
                }
            }
            if (Props.traitsToAdd.Any(x => !parent.pawn.story.traits.HasTrait(x.def)))
            {
                foreach (ExtendedTraitEntry item in Props.traitsToAdd)
                {
                    if (!parent.pawn.story.traits.HasTrait(item.def))
                    {
                        Rand.PushState();
                        if (Rand.Chance(item.Chance))
                        {
                            bool replace     = false;
                            int  countTraits = parent.pawn.story.traits.allTraits.Count;
                            if (countTraits >= maxTraits)
                            {
                                replace = true;
                            }
                            //   Log.Message(string.Format("i have {0} of a max of {1} traits", countTraits, maxTraits));
                            Trait replacedTrait = parent.pawn.story.traits.allTraits.Where(x => Props.traitsToAdd.Any(y => y.def != x.def)).RandomElement();
                            if (replace)
                            {
                                parent.pawn.story.traits.allTraits.Remove(replacedTrait);
                            }
                            parent.pawn.story.traits.allTraits.Add(new Trait(item.def, item.degree));
                        }
                        Rand.PopState();
                    }
                }
            }
            RegionListersUpdater.RegisterInRegions(parent.pawn, map);
            map.mapPawns.UpdateRegistryForPawn(parent.pawn);
            //Change BodyType to Props.bodyTypeDef
            if (!Pawn.RaceProps.hasGenders)
            {
                Pawn.gender = Gender.None;
            }
            if (Props.bodyTypeDef != null)
            {
                ChangeBodyType(parent.pawn, Props.bodyTypeDef);
            }

            //decache graphics
            parent.pawn.Drawer.renderer.graphics.ResolveAllGraphics();
            Find.ColonistBar.drawer.Notify_RecachedEntries();

            //save the pawn
            parent.pawn.ExposeData();
            if (parent.pawn.Faction != faction)
            {
                parent.pawn.SetFaction(faction);
            }
            //    pawn.Position = intv;
        }