Пример #1
0
        // Verse.Pawn
        public static string MainDesc(Pawn pawn)
        {
            string text = "ROMV_VampireDesc".Translate(new object[]
            {
                HediffVampirism.AddOrdinal(pawn.VampComp().Generation),
                pawn.VampComp().Bloodline.LabelCap
            });

            return(text.CapitalizeFirst());
        }
Пример #2
0
 public static bool TryGiveVampirismHediffFromSire(Pawn pawn, Pawn sire, bool firstVampire = false)
 {
     try
     {
         HediffVampirism vampHediff = (HediffVampirism)HediffMaker.MakeHediff(VampDefOf.ROM_Vampirism, pawn);
         vampHediff.firstVampire = firstVampire;
         vampHediff.sire         = sire.VampComp();
         vampHediff.generation   = sire.VampComp().Generation + 1;
         vampHediff.bloodline    = sire.VampComp().Bloodline;
         pawn.health.AddHediff(vampHediff, null, null);
         return(true);
     }
     catch (Exception e) { Log.Error(e.ToString()); }
     return(false);
 }
        public override void WorldComponentTick()
        {
            base.WorldComponentTick();
            if (recentVampires.Any())
            {
                recentVampires.RemoveAll(x => x.Key.Dead || x.Key.DestroyedOrNull());
            }
            if (recentVampires.Any())
            {
                var recentVampiresKeys = new List <Pawn>(recentVampires.Keys.Where(x => x.Spawned && x.Faction != Faction.OfPlayerSilentFail));

                foreach (var key in recentVampiresKeys)
                {
                    recentVampires[key] += 1;
                    if (recentVampires[key] > 100)
                    {
                        recentVampires.Remove(key);
                        tempVampires.Add(key);
                        if (!key.Spawned || key.Faction == Faction.OfPlayerSilentFail)
                        {
                            continue;
                        }
                        var generation = key?.VampComp()?.Generation;
                        if (generation != null && generation <= 8)
                        {
                            Find.LetterStack.ReceiveLetter("ROMV_PowerfulVampireLabel".Translate(),
                                                           "ROMV_PowerfulVampireDesc".Translate(new object[]
                            {
                                key.LabelShort,
                                HediffVampirism.AddOrdinal(generation.Value),
                            }), LetterDefOf.ThreatSmall, key, null);
                        }
                    }
                }
            }

            if (Find.TickManager.TicksGame % 100 == 0)
            {
                if (tempVampires.Count > 1)
                {
                    var recentVampiresKeys = new List <Pawn>(tempVampires);
                    tempVampires.Clear();
                    StringBuilder stringBuilder = new StringBuilder();
                    foreach (var pawn in recentVampiresKeys)
                    {
                        stringBuilder.AppendLine("    " + pawn.Name.ToStringShort + " (" + HediffVampirism.AddOrdinal(pawn.VampComp().Generation) + ")");
                    }
                    string vampList = "ROMV_VampiresArrivalDesc".Translate(stringBuilder.ToString());
                    Find.LetterStack.ReceiveLetter("ROMV_VampiresArrivalLabel".Translate(), vampList, LetterDefOf.ThreatSmall, recentVampiresKeys.FirstOrDefault(), null);
                }


                CleanVampGuestCache();
                if (HarmonyPatches.VampGuestCache == null || !HarmonyPatches.VampGuestCache.Any())
                {
                    return;
                }
                foreach (var keyValuePair in HarmonyPatches.VampGuestCache)
                {
                    Pawn p = keyValuePair.Key;
                    if (p == null)
                    {
                        continue;
                    }
                    if (p.Downed)
                    {
                        continue;
                    }
                    if (keyValuePair.Value + 16000 > Find.TickManager.TicksGame)
                    {
                        continue;
                    }
                    if (p.CurJob?.def == JobDefOf.Goto)
                    {
                        continue;
                    }
                    if (p.InMentalState || p.IsFighting())
                    {
                        continue;
                    }
                    if (p.IsSunRisingOrDaylight())
                    {
                        continue;
                    }
                    if (p.ParentHolder is Building_HideyHole g)
                    {
                        g.EjectContents();
                    }
                    TryGiveJobGiverToVampGuest(p);
                }
            }
        }
Пример #4
0
 public string GenRangeToString()
 {
     return(HediffVampirism.AddOrdinal(this?.generationRange.min ?? 10) + "-" + HediffVampirism.AddOrdinal(this?.generationRange.max ?? 15) ?? "");
 }