示例#1
0
        // Token: 0x06002896 RID: 10390 RVA: 0x00134DF4 File Offset: 0x001331F4
        public virtual Thing ProduceEgg()
        {
            if (!this.Active)
            {
                //    Log.Error("LayEgg while not Active: " + this.parent, false);
            }
            this.eggProgress = 0f;
            int randomInRange = this.Props.eggCountRange.RandomInRange;

            if (randomInRange == 0)
            {
                return(null);
            }
            Thing thing;

            thing = ThingMaker.MakeThing(this.Props.eggDef, null);
            this.fertilizationCount = Mathf.Max(0, this.fertilizationCount - randomInRange);

            thing.stackCount = randomInRange;
            Building_XenoEgg compHatcher = thing as Building_XenoEgg;

            if (compHatcher != null)
            {
                compHatcher.hatcheeFaction = this.parent.Faction;
                if (this.parent is Pawn pawn)
                {
                    compHatcher.hatcheeParent = pawn;
                }
            }
            return(thing);
        }
示例#2
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
                        }
                    }
                }
            }
        }