Пример #1
0
        protected override void Impregnate(Pawn pawn, Pawn part, bool isAnalSex)
        {
            if (xxx.is_human(part))
            {
                if (pawn.gender == Gender.Female)
                {
                    HediffDef_InsectEgg egg = (from x in DefDatabase <HediffDef_InsectEgg> .AllDefs where x.IsParent(pawn.def.defName) select x).RandomElement <HediffDef_InsectEgg>();
                    if (egg != null)
                    {
                        //--Log.Message("[RJW]JobDriver_RapeEnemyByInsect::aftersex() - Planting egg " + egg.ToString());
                        PlantSomething(egg, part, isAnalSex, Rand.Range(1, 2));
                    }

                    /*else
                     * {
                     *      //--Log.Message("[RJW]JobDriver_RapeEnemyByInsect::aftersex() - There is no EggData of " + pawn.def.defName);
                     * }*/
                }
                else
                {
                    //--Log.Message("[RJW]JobDriver_RapeEnemyByInsect::aftersex() - Fertilize eggs");
                    foreach (var egg in (from x in part.health.hediffSet.GetHediffs <Hediff_InsectEgg>() where x.IsParent(pawn.def.defName) select x))
                    {
                        egg.Fertilize(pawn);
                    }
                }
            }
        }
Пример #2
0
        public static void DoEgg(Pawn pawn, Pawn partner)
        {
            if (RJWPregnancySettings.insect_pregnancy_enabled)
            {
                if (RJWSettings.DevMode)
                {
                    Log.Message(" insect pregnancy");
                }

                //female "insect" plant eggs
                //futa "insect" 50% plant eggs
                if ((Genital_Helper.has_ovipositorF(pawn) && !Genital_Helper.has_ovipositorM(pawn)) ||
                    (Genital_Helper.has_ovipositorF(pawn) && Genital_Helper.has_ovipositorM(pawn) && Rand.Value > 0.5f))
                {
                    float maxeggssize = partner.BodySize * (xxx.has_quirk(partner, "Incubator") ? 2f : 1f) * (Genital_Helper.has_ovipositorF(partner) ? 2f : 0.5f);
                    float eggedsize   = 0;
                    foreach (Hediff_InsectEgg egg in partner.health.hediffSet.GetHediffs <Hediff_InsectEgg>())
                    {
                        if (egg.father != null)
                        {
                            eggedsize += egg.father.RaceProps.baseBodySize / 5;
                        }
                        else
                        {
                            eggedsize += egg.implanter.RaceProps.baseBodySize / 5;
                        }
                    }
                    if (RJWSettings.DevMode)
                    {
                        Log.Message(" determine " + xxx.get_pawnname(partner) + " size of eggs inside: " + eggedsize + ", max: " + maxeggssize);
                    }
                    if (eggedsize < maxeggssize)
                    {
                        HediffDef_InsectEgg egg = null;
                        string defname          = "";
                        float  eggssize         = pawn.RaceProps.baseBodySize / 5;

                        while (egg == null)
                        {
                            if (defname == "")
                            {
                                if (RJWSettings.DevMode)
                                {
                                    Log.Message(" trying to find " + pawn.kindDef.defName + " egg");
                                }
                                defname = pawn.kindDef.defName;
                            }
                            else
                            {
                                if (RJWSettings.DevMode)
                                {
                                    Log.Message(" no " + defname + " egg found, defaulting to Unknown egg");
                                }
                                defname = "Unknown";
                            }

                            //Rand.PopState();
                            //Rand.PushState(RJW_Multiplayer.PredictableSeed());
                            if (egg == null)
                            {
                                egg = (from x in DefDatabase <HediffDef_InsectEgg> .AllDefs where x.IsParent(defname) select x).RandomElement();
                            }
                        }
                        if (RJWSettings.DevMode)
                        {
                            Log.Message("I choose you " + egg + "!");
                        }

                        int   count;
                        float maxeggs = 100;
                        float mineggs = 0;

                        if (egg.eggsize != 0)
                        {
                            maxeggs = ((maxeggssize - eggedsize) / eggssize);
                            if (RJWSettings.DevMode)
                            {
                                Log.Message(" max eggs: " + maxeggs);
                            }
                        }
                        if (maxeggs >= 1)
                        {
                            mineggs = 1;
                        }

                        count = Rand.Range((int)mineggs, (int)(maxeggs));

                        if (RJWSettings.DevMode)
                        {
                            Log.Message(" planting eggs: " + egg.ToString() + " (" + count + ")");
                        }

                        PlantSomething(egg, partner, false, count);

                        //set implanter
                        foreach (var egg1 in partner.health.hediffSet.GetHediffs <Hediff_InsectEgg>())
                        {
                            egg1.Implanter(pawn);
                        }

                        //TODO: add widget toggle for bind all/neutral/hostile  pawns
                        if (!pawn.IsColonist)
                        {
                            if (!partner.health.hediffSet.HasHediff(HediffDef.Named("RJW_Cocoon")) && pawn.Faction != partner.Faction)
                            {
                                //if (!partner.health.hediffSet.HasHediff(HediffDef.Named("RJW_Cocoon")) && pawn.Faction != partner.Faction && pawn.HostileTo(partner))
                                partner.health.AddHediff(HediffDef.Named("RJW_Cocoon"));
                            }
                        }
                    }
                }
                //male "insect" fertilize eggs
                else if (!pawn.health.hediffSet.HasHediff(xxx.sterilized))
                {
                    foreach (var egg in (from x in partner.health.hediffSet.GetHediffs <Hediff_InsectEgg>() where x.IsParent(pawn) select x))
                    {
                        egg.Fertilize(pawn);
                    }
                }
                return;
            }
        }
Пример #3
0
        public override void Tick()
        {
            ageTicks++;
            if (!pawn.IsHashIntervalTick(10000))             // run every ~3min
            {
                return;
            }

            var partBase = def as HediffDef_PartBase;

            if (partBase != null)
            {
                if (partBase.produceEggs)
                {
                    var IsPlayerFaction = pawn.Faction?.IsPlayer ?? false;                     //colonists/animals
                    if (pawn.Map.IsPlayerHome || IsPlayerFaction || pawn.IsPrisonerOfColony)
                    {
                        ageTicks++;

                        if (nextEggTick < 0)
                        {
                            nextEggTick = Rand.Range(partBase.minEggTick, partBase.maxEggTick);
                            return;
                        }

                        if (pawn.health.capacities.GetLevel(PawnCapacityDefOf.Moving) <= 0.5)
                        {
                            return;
                        }

                        if (nextEggTick > 0 && ageTicks >= nextEggTick)
                        {
                            float maxEggsSize = (pawn.BodySize / 5) * (xxx.has_quirk(pawn, "Incubator") ? 2f : 1f) *
                                                (Genital_Helper.has_ovipositorF(pawn) ? 2f : 0.5f);
                            float eggedsize = 0;
                            foreach (var ownEgg in pawn.health.hediffSet.GetHediffs <Hediff_InsectEgg>())
                            {
                                if (ownEgg.father != null)
                                {
                                    eggedsize += ownEgg.father.RaceProps.baseBodySize / 5;
                                }
                                else
                                {
                                    eggedsize += ownEgg.implanter.RaceProps.baseBodySize / 5;
                                }
                            }

                            if (RJWSettings.DevMode)
                            {
                                Log.Message($"{xxx.get_pawnname(pawn)} filled with {eggedsize} out of max capacity of {maxEggsSize} eggs.");
                            }
                            if (eggedsize < maxEggsSize)
                            {
                                HediffDef_InsectEgg egg = null;
                                string defname          = "";

                                while (egg == null)
                                {
                                    if (defname == "")
                                    {
                                        if (RJWSettings.DevMode)
                                        {
                                            Log.Message(" trying to find " + pawn.kindDef.defName + " egg");
                                        }
                                        defname = pawn.kindDef.defName;
                                    }
                                    else
                                    {
                                        if (RJWSettings.DevMode)
                                        {
                                            Log.Message(" no " + defname + " egg found, defaulting to Unknown egg");
                                        }
                                        defname = "Unknown";
                                    }

                                    //Rand.PopState();
                                    //Rand.PushState(RJW_Multiplayer.PredictableSeed());
                                    egg = (from x in DefDatabase <HediffDef_InsectEgg> .AllDefs where x.IsParent(defname) select x)
                                          .RandomElement();
                                }

                                if (RJWSettings.DevMode)
                                {
                                    Log.Message("I choose you " + egg + "!");
                                }

                                var genitals = Genital_Helper.get_genitalsBPR(pawn);
                                if (genitals != null)
                                {
                                    var addedEgg = pawn.health.AddHediff(egg, genitals) as Hediff_InsectEgg;
                                    addedEgg?.Implanter(pawn);
                                }
                            }

                            // Reset for next egg.
                            ageTicks    = 0;
                            nextEggTick = -1;
                        }
                    }
                }
            }
        }