示例#1
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            bool selected = Find.Selector.SelectedObjects.Contains(Pawn) && Prefs.DevMode;

            base.CompPostTick(ref severityAdjustment);
            if (settings.SettingsHelper.latest.AllowXenoCocoonMetamorph)
            {
                if (!QueenPresent && !PredalienPresent)
                {
                    float num = 1f / ((3 * Pawn.BodySize) * (Pawn.RaceProps.Humanlike ? 60000f : 10000f));
                    if (this.conversionProgress < 1f)
                    {
                        this.conversionProgress += num;
                    }
                }
            }
            if (Find.TickManager.TicksGame % 300 == 0)
            {
                if (Pawn.CurrentBed() == null)
                {
                    Pawn.health.RemoveHediff(this.parent);
                }
#if DEBUG
                if (this.conversionProgress >= 1f && selected)
                {
                    Log.Message(string.Format("QueenPresent: {0}, PredalienPresent: {1}, RoyalEggPresent: {2}, RoyalPresent: {3}", QueenPresent, PredalienPresent, RoyalEggPresent, RoyalPresent));
                }
#endif
                if (!QueenPresent)
                {
                    if (this.conversionProgress >= 1f && XenomorphUtil.TotalSpawnedEggCount(MyMap) < (cocoonedCount / 2) && !XenomorphUtil.IsInfectedPawn(Pawn))
                    {
                        float chance = Pawn.RaceProps.Humanlike ? 0.001f + ((float)EggConvertTicks / 5000) : .05f + ((float)EggConvertTicks / 500);
                        EggConvertTicks++;
                        if (Rand.Chance(chance))
                        {
                            Thing            thing    = ThingMaker.MakeThing(eggDef, null);
                            Building_XenoEgg _XenoEgg = thing as Building_XenoEgg;
                            if (!RoyalEggPresent && !RoyalPresent)
                            {
                                _XenoEgg.mutateProgress = Pawn.BodySize;
                            }
                            MyCocoon.Destroy();
                            GenPlace.TryPlaceThing(thing, Pawn.Position != null ? Pawn.Position : Pawn.PositionHeld, Pawn.Map ?? Pawn.MapHeld, ThingPlaceMode.Direct);
                            //    Pawn.health.RemoveHediff(this.parent);
                            Pawn.Destroy();
                        }
                        else
                        {
#if DEBUG
                            //    Log.Message(string.Format("{0}, failed convert chance", conversionProgress));
#endif
                        }
                    }
                }
            }
        }