示例#1
0
        public static List <HediffDef> GetMarks(ThingDef x)
        {
            List <HediffDef> Marks         = new List <HediffDef>();
            bool             ArtificalPawn = x.race.FleshType.defName.Contains("Flesh_Construct") || x.race.FleshType.defName.Contains("Deamon") || x.race.body.defName.Contains("AIRobot") || x.race.IsMechanoid || (UtilChjAndroids.ChjAndroid && UtilChjAndroids.isChjAndroid(x)) || (UtilTieredAndroids.TieredAndroid && UtilTieredAndroids.isAtlasAndroid(x));

            if (x.HasModExtension <MarkDefExtension>())
            {
                if (!x.GetModExtension <MarkDefExtension>().hediffs.NullOrEmpty())
                {
                    return(x.GetModExtension <MarkDefExtension>().hediffs);
                }
                else
                {
                    Log.Warning(string.Format("MarkDefExtension found for {0} but no Hediffs found", x.defName));
                }
            }
            else
            if (ArtificalPawn)
            {
                Marks.Add(HMSDefOf.HMS_Hediff_BloodedMMechanoid);
            }
            else
            if (x.race.Humanlike)
            {
                if (x.defName.Contains("Human") || x == ThingDefOf.Human || x.race.meatDef == ThingDefOf.Meat_Human)
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMHuman);
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMWorthyHuman);
                }
                else
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMHumanlike);
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMWorthyHumanlike);
                }
            }
            else
            {
                if (x.defName.Contains("Xenomorph"))
                {
                    if (x.defName.Contains("Queen"))
                    {
                        Marks.Add(HMSDefOf.HMS_Hediff_BloodedMXenomorphQueen);
                    }
                    else if (x.defName.Contains("Predalien"))
                    {
                        Marks.Add(HMSDefOf.HMS_Hediff_BloodedMPredalien);
                    }
                    else if (x.defName.Contains("Thrumbo"))
                    {
                        Marks.Add(HMSDefOf.HMS_Hediff_BloodedMXenomorphThrumbo);
                    }
                    else
                    {
                        Marks.Add(HMSDefOf.HMS_Hediff_BloodedMXenomorph);
                    }
                }
                else if (x.defName.Contains("GroTye") || x.defName.Contains("Megasloth"))
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMGroTye);
                }
                else if ((x.defName.Contains("Rhinoceros") || x.defName.Contains("Elephant")))
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMCrusher);
                }
                else if (x.defName.Contains("Thrumbo"))
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMThrumbo);
                }
                else if (((x.defName.Contains("Wolf") || x.description.Contains("Wolf") || x.description.Contains("wolf") || x.description.Contains("wolves")) || (x.defName.Contains("Hound") || x.defName.Contains("hound") || x.description.Contains("Hound") || x.description.Contains("hound") || x.description.Contains("hounds")) || (x.defName.Contains("Dog") || x.description.Contains("Dog") || x.description.Contains("dog") || x.description.Contains("dogs"))) && x.race.body.defName.Contains("Quad") && ((x.race.predator == true)))
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMHound);
                }
                else if (x.race.Animal)
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedMBeast);
                }
                else
                {
                    Marks.Add(HMSDefOf.HMS_Hediff_BloodedM);
                }
            }
            return(Marks);
        }
        //    public static List<HediffDef> HunterMarkList = UnbloodedHediffList.Concat(BloodedUMHediffList)
        static HunterMarkingSystem()
        {
            DefDatabase <ThingDef> .AllDefsListForReading.ForEach(action : td =>
            {
                if (td.IsCorpse)
                {
                    td.comps.Add(new CompProperties_UsableCorpse()
                    {
                        compClass = typeof(Comp_KillMarker),
                        useJob    = HMSDefOf.HMS_Job_MarkSelf,
                        useLabel  = "Use {0} to mark self as Blooded"
                    });
                    td.comps.Add(new CompProperties_UseEffect()
                    {
                        compClass = typeof(CompUseEffect_MarkSelf)
                                    //     chance = 0.25f
                    });
                    //    td.tickerType = TickerType.Normal;
                }
                else
                if (td.race != null)
                {
                    if (td.race.Humanlike)
                    {
                        bool marker     = DefDatabase <HunterCultureDef> .AllDefs.Any(X => X.markerRaceDefs.Contains(td) || X.markerRaceDefs.NullOrEmpty());
                        bool allowed    = DefDatabase <HunterCultureDef> .AllDefs.Any(X => X.allowedRaceDefs.Contains(td) || X.allowedRaceDefs.NullOrEmpty());
                        bool disallowed = DefDatabase <HunterCultureDef> .AllDefs.Any(X => !X.disallowedRaceDefs.Contains(td));
                        //    Log.Message(string.Format("{0}, marker: {1}, allowed: {2}, disallowed: {3}", td.LabelCap, marker, allowed, disallowed));
                        if ((marker || allowed) && disallowed)
                        {
                            List <HunterCultureDef> releventculture = DefDatabase <HunterCultureDef> .AllDefs.Where(X => (X.markerRaceDefs.Contains(td) || X.markerRaceDefs.NullOrEmpty()) || (X.allowedRaceDefs.Contains(td) || X.allowedRaceDefs.NullOrEmpty()) && !X.disallowedRaceDefs.Contains(td)).ToList();
                            if (!releventculture.NullOrEmpty())
                            {
                                foreach (HunterCultureDef cultureDef in releventculture)
                                {
                                    if (cultureDef != null)
                                    {
                                        bool pawnflag = !((UtilChjAndroids.ChjAndroid && UtilChjAndroids.isChjAndroid(td)) || (UtilTieredAndroids.TieredAndroid && UtilTieredAndroids.isAtlasAndroid(td)) || (UtilAvPSynths.AvP && UtilAvPSynths.isAvPSynth(td)));
                                        //    Log.Message(string.Format("Checking: {0}", td.label));
                                        if (!td.HasComp(typeof(Comp_Markable)) && (pawnflag || cultureDef.AllowMechanicalMarking))
                                        {
                                            td.comps.Add(new CompProperties_Markable()
                                            {
                                                cultureDef         = cultureDef,
                                                markerRaceDefs     = cultureDef.markerRaceDefs,
                                                allowedRaceDefs    = cultureDef.allowedRaceDefs,
                                                disallowedRaceDefs = cultureDef.disallowedRaceDefs
                                            });
                                            if (td.HasComp(typeof(Comp_Markable)))
                                            {
                                                CompProperties_Markable markable = td.GetCompProperties <CompProperties_Markable>();
                                                string markerRaceDefs            = string.Empty, allowedRaceDefs = string.Empty, disallowedRaceDefs = string.Empty;
                                                markable.markerRaceDefs.ForEach(x => markerRaceDefs         += (" " + x.LabelCap));
                                                markable.allowedRaceDefs.ForEach(x => allowedRaceDefs       += (" " + x.LabelCap));
                                                markable.disallowedRaceDefs.ForEach(x => disallowedRaceDefs += (" " + x.LabelCap));
                                                //    Log.Message(string.Format("Added Comp_Markable to: {0}, cultureDef: {1}, markerRaceDefs: {2}, allowedRaceDefs: {3}, disallowedRaceDefs: {4}", td.label, markable.cultureDef.label, markerRaceDefs, allowedRaceDefs, disallowedRaceDefs));
                                            }
                                        }
                                        else
                                        {
                                        }
                                    }
                                }
                            }
                        }
                    }
                    if (DefDatabase <PawnKindDef> .AllDefs.Any(x => x.race == td) && !RaceDefaultMarkDict.Keys.Contains(td))
                    {
                        MarkData data = new MarkData(td);
                        RaceDefaultMarkDict.Add(td, data);
                    }
                }
            });

            /*
             * DefDatabase<ThingDef>.AllDefsListForReading.ForEach(action: td =>
             * {
             *  if (td.race!=null && td.isPotentialHost())
             *  {
             *      string text = string.Format("{0}'s possible Xenoforms", td.LabelCap);
             *  //    Log.Message(text);
             *
             *      foreach (var item in td.resultingXenomorph())
             *      {
             *          text = item.LabelCap;
             *      //    Log.Message(text);
             *      }
             *  }
             * });
             */
            //    Log.Message(string.Format("Hunter Marking System Loaded\n{0} Unblooded Hediffs, {1} Unmarked Hediffs, {2} Marked Hediffs deteched", UnbloodedHediffList.Count, BloodedUMHediffList.Count, BloodedMHediffList.Count));
        }