コード例 #1
0
        public override void CompTick()
        {
            base.CompTick();
            tickCounter++;

            if (tickCounter >= Props.timeToDieInTicks)
            {
                Pawn pawn = this.parent as Pawn;

                if (pawn != null && pawn.Map != null)
                {
                    if (Props.effect)
                    {
                        for (int i = 0; i < 20; i++)
                        {
                            IntVec3 c;
                            CellFinder.TryFindRandomReachableCellNear(this.parent.Position, this.parent.Map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
                            FilthMaker.TryMakeFilth(c, this.parent.Map, ThingDef.Named(Props.effectFilth));
                        }
                        SoundDefOf.Hive_Spawn.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
                    }
                    pawn.Kill(null);
                }
                tickCounter = 0;
            }
        }
コード例 #2
0
        public override void CompTickRare()
        {
            base.CompTickRare();
            metamorphosisTick++;
            if (metamorphosisTick > rareTicksInAYear * Props.timeInYears)
            {
                Faction faction = this.parent.Faction;



                PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.pawnToTurnInto), faction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                Pawn pawn = PawnGenerator.GeneratePawn(request);
                GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(parent.Position, parent.Map, 3, null), parent.Map, WipeMode.Vanish);



                for (int i = 0; i < 20; i++)
                {
                    IntVec3 c;
                    CellFinder.TryFindRandomReachableCellNear(this.parent.Position, this.parent.Map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
                    FilthMaker.TryMakeFilth(c, this.parent.Map, ThingDefOf.Filth_AmnioticFluid);
                }


                SoundDefOf.Hive_Spawn.PlayOneShot(new TargetInfo(this.parent.Position, this.parent.Map, false));
                this.parent.Destroy();
            }
        }
コード例 #3
0
        public void popBlood(Pawn pawn, Corpse corpse)
        {
            IntVec3  pos   = IntVec3.Zero;
            Map      map   = null;
            ThingDef blood = ThingDefOf.Filth_Blood;

            if (pawn != null)
            {
                pos = pawn.Position;
                map = pawn.Map;
                if (pawn.def.race.Insect)
                {
                    blood = ThingDef.Named("Filth_BloodInsect");
                }
            }
            if (corpse != null)
            {
                pos = corpse.Position;
                map = corpse.Map;
                if (corpse.InnerPawn.def.race.Insect)
                {
                    blood = ThingDef.Named("Filth_BloodInsect");
                }
            }


            for (int i = 0; i < 20; i++)
            {
                IntVec3 c;
                CellFinder.TryFindRandomReachableCellNear(pos, map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
                FilthMaker.TryMakeFilth(c, map, blood);
            }
        }
コード例 #4
0
ファイル: Patch.cs プロジェクト: Jaxe-Dev/Collapser
        private static bool Prefix(IntVec3 c, Map map)
        {
            var roofDef = map.roofGrid.RoofAt(c);

            if (roofDef == null)
            {
                return(false);
            }

            if (roofDef.filthLeaving != null)
            {
                FilthMaker.TryMakeFilth(c, map, roofDef.filthLeaving);
            }

            if (roofDef.VanishOnCollapse)
            {
                map.roofGrid.SetRoof(c, null);
            }
            else if (AdjacentUnroofedTiles(c, map) > 0)
            {
                map.roofGrid.SetRoof(c, null);
            }

            var bound = CellRect.CenteredOn(c, 2);

            foreach (var pawn2 in map.mapPawns.AllPawnsSpawned.Where(pawn => bound.Contains(pawn.Position)))
            {
                TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, pawn2);
            }

            return(false);
        }
コード例 #5
0
        public override void Tick()
        {
            if (Spawned)
            {
                sustainer.Maintain();
                Vector3 vector = Position.ToVector3Shifted();
                IntVec3 c;
                if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 5.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(Position, Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999))
                {
                    FilthMaker.TryMakeFilth(c, Map, RatkinTunnelUtility.filthTypes.RandomElement <ThingDef>(), 1);
                }

                if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
                {
                    MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
                    {
                        y = AltitudeLayer.MoteOverhead.AltitudeFor()
                    }, Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
                }
                if (secondarySpawnTick <= Find.TickManager.TicksGame)
                {
                    sustainer.End();
                    Map     map      = Map;
                    IntVec3 position = Position;
                    Destroy(DestroyMode.Vanish);
                    if (spawnTunnel)
                    {
                        Building_ThiefTunnel tunnel = (Building_ThiefTunnel)GenSpawn.Spawn(ThingMaker.MakeThing(RatkinBuildingDefOf.RK_ThiefTunnel, null), position, map, WipeMode.Vanish);
                        tunnel.SetFaction(Find.FactionManager.FirstFactionOfDef(RatkinFactionDefOf.Rakinia), null);
                    }
                }
            }
        }
コード例 #6
0
ファイル: Harvest.cs プロジェクト: emipa606/AutopsyTable
    public static void Postfix(ref IEnumerable <Thing> __result, ref Corpse __instance, Pawn butcher)
    {
        if (butcher.CurJob?.GetTarget(TargetIndex.A).Thing == null ||
            butcher.CurJob.GetTarget(TargetIndex.A).Thing.def.defName != "TableAutopsy")
        {
            return;
        }

        if (butcher.CurJob?.RecipeDef?.defName == "AutopsyHumanoid")
        {
            return;
        }

        var table         = butcher.CurJob.GetTarget(TargetIndex.A).Thing as Building_WorkTable;
        var valuableItems = __instance.InnerPawn.DetachValuableItems(table, butcher).ToList();

        valuableItems.AddRange(__result);
        if (__instance.InnerPawn.RaceProps.BloodDef != null)
        {
            FilthMaker.TryMakeFilth(butcher.Position, butcher.Map, __instance.InnerPawn.RaceProps.BloodDef,
                                    __instance.InnerPawn.LabelIndefinite());
        }

        __result = valuableItems;
    }
コード例 #7
0
 public override IEnumerable <Thing> ButcherProducts(Pawn butcher, float efficiency)
 {
     foreach (Thing item in InnerPawn.ButcherProducts(butcher, efficiency))
     {
         yield return(item);
     }
     if (InnerPawn.RaceProps.BloodDef != null)
     {
         FilthMaker.TryMakeFilth(butcher.Position, butcher.Map, InnerPawn.RaceProps.BloodDef, InnerPawn.LabelIndefinite());
     }
     if (!InnerPawn.RaceProps.Humanlike)
     {
         yield break;
     }
     if (butcher.needs.mood != null)
     {
         butcher.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.ButcheredHumanlikeCorpse);
     }
     foreach (Pawn item2 in butcher.Map.mapPawns.SpawnedPawnsInFaction(butcher.Faction))
     {
         if (item2 != butcher && item2.needs != null && item2.needs.mood != null && item2.needs.mood.thoughts != null)
         {
             item2.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.KnowButcheredHumanlikeCorpse);
         }
     }
     TaleRecorder.RecordTale(TaleDefOf.ButcheredHumanlikeCorpse, butcher);
 }
コード例 #8
0
        public override void CompPostTick(ref float severityAdjustment)
        {
            myPawn = parent.pawn;

            if (myPawn == null)
            {
                Tools.Warn("pawn null", myDebug);
                return;
            }
            if (myPawn.Map == null)
            {
                //Tools.Warn(myPawn.Label + " - pawn.Map null", myDebug);
                return;
            }
            if (Props.filthDef == null)
            {
                return;
            }

            // Puff
            if (this.filthTicksLeft <= 0)
            {
                FilthMaker.TryMakeFilth(myPawn.Position, myPawn.Map, Props.filthDef);
                filthTicksLeft = ticksUntilFilth = Rand.RangeInclusive(Props.MinTicksBetweenSprays, Props.MaxTicksBetweenSprays);
            }
            // decrease ticks
            else
            {
                this.filthTicksLeft--;
            }
        }
コード例 #9
0
 // Token: 0x06002628 RID: 9768 RVA: 0x001222BC File Offset: 0x001206BC
 public override void Tick()
 {
     if (base.Spawned)
     {
         this.sustainer.Maintain();
         Vector3 vector = base.Position.ToVector3Shifted();
         IntVec3 c;
         // throws dust and filth
         Rand.PushState();
         if (Rand.MTBEventOccurs(TunnelRaidSpawner.FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TunnelRaidSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999))
         {
             FilthMaker.TryMakeFilth(c, base.Map, TunnelRaidSpawner.filthTypes.RandomElement <ThingDef>(), 1);
         }
         if (Rand.MTBEventOccurs(TunnelRaidSpawner.DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
         {
             FleckMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
             {
                 y = AltitudeLayer.MoteOverhead.AltitudeFor()
             }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
         }
         Rand.PopState();
         if (this.secondarySpawnTick <= Find.TickManager.TicksGame)
         {
             this.sustainer.End();
             List <Pawn> list = new List <Pawn>();
             SpawnThings(out list);
             this.Destroy(DestroyMode.Vanish);
         }
     }
 }
コード例 #10
0
ファイル: Ballista.cs プロジェクト: tptp7979/NewRatkin
        protected override void Impact(Thing hitThing)
        {
            Map map = Map;
            BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher, hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);

            Find.BattleLog.Add(battleLogEntry_RangedImpact);
            if (hitThing != null)
            {
                DamageDef  damageDef        = def.projectile.damageDef;
                float      amount           = DamageAmount;
                float      armorPenetration = ArmorPenetration;
                float      y            = ExactRotation.eulerAngles.y;
                Thing      launcher     = this.launcher;
                ThingDef   equipmentDef = this.equipmentDef;
                DamageInfo dinfo        = new DamageInfo(damageDef, amount, armorPenetration, y, launcher, null, equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown, this.intendedTarget.Thing);
                hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                Pawn pawn = hitThing as Pawn;
                if (pawn != null && pawn.stances != null && pawn.BodySize <= def.projectile.StoppingPower + 0.001f)
                {
                    pawn.stances.StaggerFor(95);
                }
                RKSoundDefOf.Ballista_Impact.PlayOneShot(new TargetInfo(hitThing.Position, map, false));
                FilthMaker.TryMakeFilth(Position, map, ThingDefOf.Filth_Blood, 4);
            }
            else
            {
                MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_Bombardment, 1f);
                if (Position.GetTerrain(map).takeSplashes)
                {
                    MoteMaker.MakeBombardmentMote(this.DestinationCell, map, 4f);
                }
            }
            Explode();
        }
コード例 #11
0
 public void DropBloodFilth()
 {
     if ((pawn.Spawned || pawn.ParentHolder is Pawn_CarryTracker) && pawn.SpawnedOrAnyParentSpawned && pawn.RaceProps.BloodDef != null)
     {
         FilthMaker.TryMakeFilth(pawn.PositionHeld, pawn.MapHeld, pawn.RaceProps.BloodDef, pawn.LabelIndefinite());
     }
 }
コード例 #12
0
        private void checkAllThatInsidesForGunk()
        {
            bool ohHellNahWeAMutant = false;

            foreach (BodyPartDef astarteBodyPart in Constants.AstarteBodyParts)
            {
                IEnumerable <BodyPartRecord> bodyPartRecords =
                    pawn.def.race.body.GetPartsWithDef(astarteBodyPart).ToList();
                if (bodyPartRecords.Count() <= 1)
                {
                    continue;
                }
                ohHellNahWeAMutant = true;
                Log.Message(
                    "Uh Oh this Astarte is a damn mutant, they got more than one copy of the astarte organs [" +
                    bodyPartRecords.First() + "]");
                FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.Filth_Blood, 6);
                break;
            }

            if (!ohHellNahWeAMutant)
            {
                return;
            }
        }
コード例 #13
0
        public override void Tick()
        {
            base.Tick();
            if (Find.TickManager.TicksGame % 250 == 0)
            {
                this.TickRare();
            }
            this.mindState.mentalStateHandler.neverFleeIndividual = true;

            if (this.health.hediffSet.HasTendableInjury())
            {
                this.TickHeal(true);
            }
            if (!base.Dead || !base.Downed)
            {
                int num = this.ticksSinceStatusUpdate;
                this.ticksSinceStatusUpdate = num + 1;
                if (this.ticksSinceStatusUpdate >= this.updateStatusEveryXTicks)
                {
                    IntVec3  intVec = CellFinder.RandomClosewalkCellNear(base.Position, base.Map, 1);
                    ThingDef named  = DefDatabase <ThingDef> .GetNamed("Filth_Blood", true);

                    FilthMaker.TryMakeFilth(intVec, base.Map, named, 1);
                    this.ticksSinceStatusUpdate = 0;
                }
            }
            if (base.Downed)
            {
                IntVec3  intVec2 = CellFinder.RandomClosewalkCellNear(base.Position, base.Map, 2);
                ThingDef named2  = DefDatabase <ThingDef> .GetNamed("Filth_Blood", true);

                FilthMaker.TryMakeFilth(intVec2, base.Map, named2, 3);
                HealthUtility.DamageUntilDead(this);
            }
        }
コード例 #14
0
 // Token: 0x06002628 RID: 9768 RVA: 0x001222BC File Offset: 0x001206BC
 public override void Tick()
 {
     if (base.Spawned)
     {
         this.sustainer.Maintain();
         Vector3 vector = base.Position.ToVector3Shifted();
         IntVec3 c;
         Rand.PushState();
         if (Rand.MTBEventOccurs(TunnelSpawner.FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TunnelSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999))
         {
             FilthMaker.TryMakeFilth(c, base.Map, TunnelSpawner.filthTypes.RandomElement <ThingDef>(), 1);
         }
         if (Rand.MTBEventOccurs(TunnelSpawner.DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
         {
             MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
             {
                 y = AltitudeLayer.MoteOverhead.AltitudeFor()
             }, base.Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
         }
         Rand.PopState();
         if (this.secondarySpawnTick <= Find.TickManager.TicksGame)
         {
             this.sustainer.End();
             Map     map      = base.Map;
             IntVec3 position = base.Position;
             if (!this.innerContainer.NullOrEmpty())
             {
                 //    Log.Message(string.Format("{0} to drop", innerContainer.ContentsString));
                 this.innerContainer.TryDropAll(position, map, ThingPlaceMode.Near);
             }
             this.Destroy(DestroyMode.Vanish);
         }
     }
 }
コード例 #15
0
 public static void TrySpawnFilth(Thing refT, float filthRadius, ThingDef filthDef)
 {
     if (refT.Map != null && CellFinder.TryFindRandomReachableCellNear(refT.Position, refT.Map, filthRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors), (IntVec3 x) => x.Standable(refT.Map), (Region x) => true, out IntVec3 result))
     {
         FilthMaker.TryMakeFilth(result, refT.Map, filthDef);
     }
 }
コード例 #16
0
 public override void Notify_PawnKilled()
 {
     base.Notify_PawnKilled();
     //base.Pawn.equipment.DestroyAllEquipment();
     //base.Pawn.apparel.DestroyAll();
     if (!Pawn.Spawned)
     {
         return;
     }
     if (Props.mote != null)
     {
         Vector3 drawPos = Pawn.DrawPos;
         for (int i = 0; i < Props.moteCount; i++)
         {
             Vector2 vector = Rand.InsideUnitCircle * Props.moteOffsetRange.RandomInRange * Rand.Sign;
             MoteMaker.MakeStaticMote(new Vector3(drawPos.x + vector.x, drawPos.y, drawPos.z + vector.y), Pawn.Map, Props.mote);
         }
     }
     if (Props.filth != null)
     {
         FilthMaker.TryMakeFilth(Pawn.Position, Pawn.Map, Props.filth, Props.filthCount);
     }
     if (Props.sound != null)
     {
         Props.sound.PlayOneShot(SoundInfo.InMap(Pawn));
     }
     if (Props.thing != null)
     {
         Thing thing = ThingMaker.MakeThing(Props.thing, Props.thingStuff);
         thing.stackCount = Props.thingCount;
         GenSpawn.Spawn(thing, Pawn.Position, Pawn.Map, WipeMode.FullRefund);
     }
 }
コード例 #17
0
        public override DamageResult Apply(DamageInfo dinfo, Thing victim)
        {
            Pawn pawn = victim as Pawn;

            if (pawn != null && pawn.Faction == Faction.OfPlayer)
            {
                Find.TickManager.slower.SignalForceNormalSpeedShort();
            }
            Map          map          = victim.Map;
            DamageResult damageResult = base.Apply(dinfo, victim);

            if (!damageResult.deflected && !dinfo.InstantPermanentInjury && Rand.Chance(FireUtility.ChanceToAttachFireFromEvent(victim)))
            {
                victim.TryAttachFire(Rand.Range(0.15f, 0.25f));
            }
            if (victim.Destroyed && map != null && pawn == null)
            {
                foreach (IntVec3 item in victim.OccupiedRect())
                {
                    FilthMaker.TryMakeFilth(item, map, ThingDefOf.Filth_Ash);
                }
                Plant plant = victim as Plant;
                if (plant != null && victim.def.plant.IsTree && plant.LifeStage != 0 && victim.def != ThingDefOf.BurnedTree)
                {
                    ((DeadPlant)GenSpawn.Spawn(ThingDefOf.BurnedTree, victim.Position, map)).Growth = plant.Growth;
                }
            }
            return(damageResult);
        }
コード例 #18
0
        // Token: 0x060000DC RID: 220 RVA: 0x00006E0C File Offset: 0x0000500C
        public override DamageWorker.DamageResult Apply(DamageInfo dinfo, Thing victim)
        {
            Pawn pawn = victim as Pawn;

            if (pawn != null && pawn.Faction == Faction.OfPlayer)
            {
                Find.TickManager.slower.SignalForceNormalSpeedShort();
            }
            Map map = victim.Map;

            DamageWorker.DamageResult damageResult = base.Apply(dinfo, victim);
            if (!damageResult.deflected && !dinfo.InstantPermanentInjury)
            {
                victim.TryAttachFire(Rand.Range(0.15f, 0.25f));
            }
            if (victim.Destroyed && map != null && pawn == null)
            {
                foreach (IntVec3 intVec in victim.OccupiedRect())
                {
                    FilthMaker.TryMakeFilth(intVec, map, ThingDefOf.Filth_Ash, 1);
                }
                if (victim is Plant plant && victim.def.plant.IsTree && plant.LifeStage != PlantLifeStage.Sowing && victim.def != ThingDefOf.BurnedTree)
                {
                    ((DeadPlant)GenSpawn.Spawn(ThingDefOf.BurnedTree, victim.Position, map, WipeMode.Vanish)).Growth = plant.Growth;
                }
            }
            return(damageResult);
        }
コード例 #19
0
        public override void Tick()
        {
            base.Tick();

            if (!Settings.allowPawnsToGetWet || !this.pawn.Position.IsValid || this.pawn.MapHeld == null || !this.pawn.Position.InBounds(this.pawn.MapHeld))
            {
                return;
            }

            float wetness = this.wetnessRate();

            if (wetness > 0)
            {
                this.Severity     += wetness / 1000;
                this.wetnessLevel += wetness;
                if (this.wetnessLevel < 0)
                {
                    this.wetnessLevel = 0;
                }
                if (this.Severity > .62 && (this.ageTicks % 1000 == 0))
                {
                    FilthMaker.TryMakeFilth(this.pawn.Position, this.pawn.MapHeld, ThingDef.Named("TKKN_FilthPuddle"), 1);
                    this.Severity -= .3f;
                }
            }
            else
            {
                this.Severity += wetness / 1000;
            }
        }
コード例 #20
0
 public static void TryCastNextBurstShot_Postfix(Verb __instance)
 {
     if (__instance?.verbProps != null && __instance.EquipmentSource != null && __instance.verbProps.muzzleFlashScale > 0.01f && __instance.verbProps.verbClass != typeof(Verb_ShootOneUse))
     {
         if (__instance.CasterPawn != null && __instance.GetProjectile()?.projectile != null && __instance.CasterIsPawn)
         {
             ThingDef filth = BulletCasingMoteDefOf.Filth_BulletCasingsCharge;
             if (__instance.CasterPawn.equipment.Primary.def.defName.Contains("Charge", StringComparison.OrdinalIgnoreCase))
             {
                 ThrowCasing(__instance.CasterPawn, __instance.caster.Map, __instance.GetProjectile().projectile.GetDamageAmount(1f), BulletCasingMoteDefOf.Mote_BulletCasing_Charge);
             }
             else if (__instance.CasterPawn.equipment.Primary.def.defName.Contains("Shotgun", StringComparison.OrdinalIgnoreCase))
             {
                 ThrowCasing(__instance.CasterPawn, __instance.caster.Map, __instance.GetProjectile().projectile.GetDamageAmount(1f), BulletCasingMoteDefOf.Mote_BulletCasing_Shotgun);
                 filth = BulletCasingMoteDefOf.Filth_BulletCasingsShotgun;
             }
             else
             {
                 ThrowCasing(__instance.CasterPawn, __instance.caster.Map, __instance.GetProjectile().projectile.GetDamageAmount(1f), BulletCasingMoteDefOf.Mote_BulletCasing);
                 filth = BulletCasingMoteDefOf.Filth_BulletCasingsRifle;
             }
             if (Rand.Value > 0.9f && BulletCasingMoteSettings.filth)
             {
                 IntVec3 randomCell = new IntVec3(Rand.Range(__instance.caster.Position.x - 1, __instance.caster.Position.x + 1), 0, Rand.Range(__instance.caster.Position.z - 1, __instance.caster.Position.z + 1));
                 FilthMaker.TryMakeFilth(randomCell, __instance.caster.Map, filth);
             }
         }
         else if (__instance.caster != null && __instance.caster.def != ThingDefOf.Turret_Mortar)
         {
             ThrowCasingTurret(__instance.caster, __instance.caster.Map, __instance.GetProjectile().projectile.GetDamageAmount(1f), BulletCasingMoteDefOf.Mote_BulletCasing);
         }
     }
 }
コード例 #21
0
        /*
         * PawnKindDef MyPawnKindDefNamed (string myDefName)
         * {
         *  PawnKindDef answer = null;
         *  foreach (PawnKindDef curPawnKindDef in DefDatabase<PawnKindDef>.AllDefs)
         *  {
         *      if (curPawnKindDef.defName == myDefName)
         *          return curPawnKindDef;
         *  }
         *  return answer;
         * }
         */

        public bool TrySpawnPawn()
        {
            /*
             * public PawnGenerationRequest(
             * 1   PawnKindDef kind, Faction faction = null, PawnGenerationContext context = PawnGenerationContext.NonPlayer, int tile = -1, bool forceGenerateNewPawn = false,
             * 2   bool newborn = false, bool allowDead = false, bool allowDowned = false, bool canGeneratePawnRelations = true, bool mustBeCapableOfViolence = false,
             * 3   float colonistRelationChanceFactor = 1, bool forceAddFreeWarmLayerIfNeeded = false, bool allowGay = true, bool allowFood = true, bool allowAddictions = true,
             * 4   bool inhabitant = false, bool certainlyBeenInCryptosleep = false, bool forceRedressWorldPawnIfFormerColonist = false, bool worldPawnFactionDoesntMatter = false, float biocodeWeaponChance = 0,
             * 5   Pawn extraPawnForExtraRelationChance = null, float relationWithExtraPawnChanceFactor = 1, Predicate<Pawn> validatorPreGear = null, Predicate<Pawn> validatorPostGear = null, IEnumerable<TraitDef> forcedTraits = null,
             * 6   IEnumerable<TraitDef> prohibitedTraits = null, float? minChanceToRedressWorldPawn = null, float? fixedBiologicalAge = null, float? fixedChronologicalAge = null, Gender? fixedGender = null,
             * 7   float? fixedMelanin = null, string fixedLastName = null, string fixedBirthName = null, RoyalTitleDef fixedTitle = null);
             */

            PawnGenerationRequest request = new PawnGenerationRequest(
                CurIP.pawnKindToSpawn, Itemfaction, PawnGenerationContext.NonPlayer, -1, false, newBorn);

            for (int i = 0; i < calculatedQuantity; i++)
            {
                Pawn NewBorn = PawnGenerator.GeneratePawn(request);
                GenSpawn.Spawn(NewBorn, Pawn.Position, Pawn.Map, WipeMode.Vanish);

                if (CurIP.HasFilth)
                {
                    FilthMaker.TryMakeFilth(parent.pawn.Position, parent.pawn.Map, CurIP.filthDef, 1);
                }
            }

            return(true);
        }
コード例 #22
0
        public static bool DropFilthDueToDamage(Thing t, float damageDealt)
        {
            List <IntVec3> tmpCellsCandidates = new List <IntVec3>();

            if (!t.def.useHitPoints || !t.Spawned || t.def.filthLeaving == null)
            {
                return(false);
            }

            CellRect cellRect = t.OccupiedRect().ExpandedBy(1);

            tmpCellsCandidates.Clear();
            foreach (IntVec3 item in cellRect)
            {
                if (item.InBounds(t.Map) && item.Walkable(t.Map))
                {
                    tmpCellsCandidates.Add(item);
                }
            }

            if (tmpCellsCandidates.Any())
            {
                int num = GenMath.RoundRandom(damageDealt * Mathf.Min(0.0166666675f, 1f / ((float)t.MaxHitPoints / 10f)));
                for (int i = 0; i < num; i++)
                {
                    FilthMaker.TryMakeFilth(tmpCellsCandidates.RandomElement(), t.Map, t.def.filthLeaving);
                }

                //tmpCellsCandidates.Clear();
            }
            return(false);
        }
コード例 #23
0
 public override void Notify_PawnKilled()
 {
     base.Pawn.equipment?.DestroyAllEquipment(DestroyMode.Vanish);
     base.Pawn.apparel?.DestroyAll(DestroyMode.Vanish);
     if (!base.Pawn.Spawned)
     {
         return;
     }
     Detonate(base.Pawn.Map, false, false);
     if (this.Props.mote != null)
     {
         Vector3 drawPos = base.Pawn.DrawPos;
         for (int i = 0; i < this.Props.moteCount; i++)
         {
             Vector2 vector = Rand.InsideUnitCircle * this.Props.moteOffsetRange.RandomInRange * (float)Rand.Sign;
             MoteMaker.MakeStaticMote(new Vector3(drawPos.x + vector.x, drawPos.y, drawPos.z + vector.y), base.Pawn.Map, this.Props.mote, 1f);
         }
     }
     if (this.Props.filth != null)
     {
         FilthMaker.TryMakeFilth(base.Pawn.Position, base.Pawn.Map, this.Props.filth, this.Props.filthCount, FilthSourceFlags.None);
     }
     if (this.Props.sound != null)
     {
         this.Props.sound.PlayOneShot(SoundInfo.InMap(base.Pawn, MaintenanceType.None));
     }
 }
コード例 #24
0
        static void Postfix(Pawn_FilthTracker __instance)
        {
            // A copy of the normal human-like filth generation, only with a much higher chance to generate filth.
            Pawn pawn = AccessTools.Field(typeof(Pawn_FilthTracker), "pawn").GetValue(__instance) as Pawn;

            if (pawn?.story?.traits?.HasTrait(GMT_DefOf.GMT_Slob) ?? false)
            {
                if (Rand.Value < PawnUtility.HumanFilthChancePerCell(pawn.def, pawn.BodySize) * GMT_Slob_Helper.slob_factor)
                {
                    ThingDef filth_Trash;
                    ThingDef lastTerrainFilthDef = AccessTools.Field(typeof(Pawn_FilthTracker), "lastTerrainFilthDef").GetValue(__instance) as ThingDef;
                    if (lastTerrainFilthDef != null && Rand.Chance(0.66f))
                    {
                        filth_Trash = lastTerrainFilthDef;
                    }
                    else
                    {
                        filth_Trash = ThingDefOf.Filth_Trash;
                    }
                    if (FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, filth_Trash, 1, (FilthSourceFlags)AccessTools.Method(typeof(Pawn_FilthTracker), "get_AdditionalFilthSourceFlags").Invoke(__instance, null)))
                    {
                        AccessTools.TypeByName("RimWorld.FilthMonitor").GetMethod("Notify_FilthHumanGenerated").Invoke(null, null);
                    }
                }
            }
        }
 private static IEnumerable <Thing> ButcherProducts(Corpse __instance, Pawn butcher, float efficiency)
 {
     foreach (Thing t in __instance.InnerPawn.ButcherProducts(butcher, efficiency))
     {
         yield return(t);
     }
     if (bloodReplacer != null)
     {
         if (bloodReplacer.bloodDef != null)
         {
             FilthMaker.TryMakeFilth(butcher.Position, butcher.Map, bloodReplacer.bloodDef, __instance.InnerPawn.LabelIndefinite(), 1);
         }
     }
     if (__instance.InnerPawn.RaceProps.Humanlike)
     {
         butcher.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.ButcheredHumanlikeCorpse, null);
         foreach (Pawn pawn in butcher.Map.mapPawns.SpawnedPawnsInFaction(butcher.Faction))
         {
             if (pawn != butcher && pawn.needs != null && pawn.needs.mood != null && pawn.needs.mood.thoughts != null)
             {
                 pawn.needs.mood.thoughts.memories.TryGainMemory(ThoughtDefOf.KnowButcheredHumanlikeCorpse, null);
             }
         }
         TaleRecorder.RecordTale(TaleDefOf.ButcheredHumanlikeCorpse, new object[]
         {
             butcher
         });
     }
     yield break;
 }
コード例 #26
0
        public override void Notify_PawnDied()
        {
            Map map = this.parent.pawn.Corpse.Map;

            if (map != null)
            {
                if (naturalDeath)
                {
                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.turnTo), null, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent.pawn.Corpse);
                    pawn.Kill(null);
                    this.parent.pawn.Corpse.Destroy();
                }
                else
                {
                    Gender  oldGender             = this.parent.pawn.gender;
                    Faction faction               = Find.FactionManager.FirstFactionOfDef(FactionDefOf.AncientsHostile);
                    PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDef.Named(Props.turnTo), faction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, false, false);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent.pawn.Corpse);
                    pawn.gender = oldGender;
                    pawn.mindState.mentalStateHandler.TryStartMentalState(DefDatabase <MentalStateDef> .GetNamed("ManhunterPermanent", true), null, true, false, null, false);
                    for (int i = 0; i < 20; i++)
                    {
                        IntVec3 c;
                        CellFinder.TryFindRandomReachableCellNear(this.parent.pawn.Corpse.Position, map, 2, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c);
                        FilthMaker.TryMakeFilth(c, this.parent.pawn.Corpse.Map, ThingDefOf.Filth_Blood);
                    }
                    SoundDefOf.Hive_Spawn.PlayOneShot(new TargetInfo(this.parent.pawn.Corpse.Position, map, false));
                    this.parent.pawn.Corpse.Destroy();
                }
            }
        }
コード例 #27
0
        protected override IEnumerable <Toil> MakeNewToils()
        {
            // Go to hairdressing table
            var gotoToil = Toils_Goto.GotoThing(TableIndex, PathEndMode.InteractionCell);

            yield return(gotoToil);

            // Bring up interface
            yield return(new Toil()
            {
                initAction = () =>
                {
                    Find.WindowStack.Add(new Dialog_ChangeHairstyle(this));
                },
                defaultCompleteMode = ToilCompleteMode.Never
            });

            // Change hairstyle
            var hairdressToil = new Toil
            {
                tickAction = () =>
                {
                    // Work on changing hairstyle
                    restyleTicksDone += pawn.GetStatValue(RimWorld.StatDefOf.GeneralLaborSpeed);
                    if (restyleTicksDone >= ticksToRestyle)
                    {
                        if (AnyChanges)
                        {
                            FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, ThingDefOf.VHE_Filth_Hair, 3);
                        }

                        if (newHairDef != null)
                        {
                            pawn.story.hairDef = newHairDef;
                        }
                        if (newHairColour.HasValue)
                        {
                            pawn.story.hairColor = newHairColour.Value;
                        }

                        if (newBeardDef != null)
                        {
                            this.pawn.style.beardDef = newBeardDef;
                        }

                        pawn.Drawer.renderer.graphics.ResolveAllGraphics();
                        PortraitsCache.SetDirty(pawn);
                        GlobalTextureAtlasManager.TryMarkPawnFrameSetDirty(pawn);
                        pawn.jobs.EndCurrentJob(JobCondition.Succeeded);
                    }
                },
                defaultCompleteMode = ToilCompleteMode.Never
            };

            hairdressToil.WithProgressBar(TableIndex, () => restyleTicksDone / ticksToRestyle, true);
            hairdressToil.FailOnCannotTouch(TableIndex, PathEndMode.Touch);
            hairdressToil.PlaySustainerOrSound(SoundDefOf.Recipe_Tailor);
            yield return(hairdressToil);
        }
コード例 #28
0
        public void Hatch()
        {
            try
            {
                int         present    = this.parent.Map?.mapPawns.AllPawns.Where(x => x.def == this.Props.hatcherPawn.race).Count() ?? 0;
                int         spawnCount = this.parent.stackCount;
                PawnKindDef spawnKind  = this.Props.hatcherPawn;
                if (present > this.Props.minForHorde)
                {
                    Rand.PushState();
                    if (Rand.Chance(this.Props.hordeChance))
                    {
                        spawnCount += this.Props.hordeSpawns;
                        spawnKind   = this.Props.hordePawn;
                    }
                    Rand.PopState();
                }
                PawnGenerationRequest request = new PawnGenerationRequest(spawnKind, this.hatcheeFaction, PawnGenerationContext.NonPlayer, -1, false, true, false, false, true, false, 1f, false, true, true, true, false, false, false, false, 0f, 0f, null, 1f, null, null, null, null, null, null, null, null, null, null, null, null);

                for (int i = 0; i < spawnCount; i++)
                {
                    //	Log.Message("Spawning pawn "+(i+1)+ " of " +spawnCount);
                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    if (PawnUtility.TrySpawnHatchedOrBornPawn(pawn, this.parent))
                    {
                        if (pawn != null)
                        {
                            if (this.hatcheeParent != null)
                            {
                                if (pawn.playerSettings != null && this.hatcheeParent.playerSettings != null && this.hatcheeParent.Faction == this.hatcheeFaction)
                                {
                                    pawn.playerSettings.AreaRestriction = this.hatcheeParent.playerSettings.AreaRestriction;
                                }
                                if (pawn.RaceProps.IsFlesh)
                                {
                                    pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.hatcheeParent);
                                }
                            }
                            if (this.otherParent != null && (this.hatcheeParent == null || this.hatcheeParent.gender != this.otherParent.gender) && pawn.RaceProps.IsFlesh)
                            {
                                pawn.relations.AddDirectRelation(PawnRelationDefOf.Parent, this.otherParent);
                            }
                        }
                        if (this.parent.Spawned)
                        {
                            FilthMaker.TryMakeFilth(this.parent.Position, this.parent.Map, ThingDefOf.Filth_AmnioticFluid, 1, FilthSourceFlags.None);
                        }
                    }
                    else
                    {
                        Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                    }
                }
            }
            finally
            {
                this.parent.Destroy(DestroyMode.Vanish);
            }
        }
コード例 #29
0
        public override void GameConditionTick()
        {
            base.GameConditionTick();

            IntVec3 newFilthLoc = CellFinderLoose.RandomCellWith((IntVec3 sq) => sq.Standable(AffectedMaps[0]) && !AffectedMaps[0].roofGrid.Roofed(sq), AffectedMaps[0], 1000);

            FilthMaker.TryMakeFilth(newFilthLoc, AffectedMaps[0], ThingDefOf.Filth_Vomit);
        }
コード例 #30
0
        public override bool TryExecuteWorker(IncidentParms parms)
        {
            Map          map                 = (Map)parms.target;
            List <Thing> listOfTerminals     = map.listerThings.ThingsOfDef(ReplimatDef.ReplimatTerminal);
            List <Thing> listOfAnimalFeeders = map.listerThings.ThingsOfDef(ReplimatDef.ReplimatAnimalFeeder);
            List <Thing> list                = listOfTerminals.Concat(listOfAnimalFeeders).ToList();

            if (!list.Any())
            {
                // If there are no Terminals or Animal Feeders, break out of execution early
                return(false);
            }

            Thing targetTerminal = list.RandomElement();

            int volumeOfFeedstockToSpill = 3; // Volume in litres

            if (targetTerminal.def == ReplimatDef.ReplimatTerminal)
            {
                if (targetTerminal is Building_ReplimatTerminal currentTerminal && currentTerminal.HasEnoughFeedstockInHopperForIncident(volumeOfFeedstockToSpill))
                {
                    currentTerminal.powerComp.PowerNet.TryConsumeFeedstock(volumeOfFeedstockToSpill);
                    ThingDef filthSlime = ThingDefOf.Filth_Slime;
                    FilthMaker.TryMakeFilth(targetTerminal.InteractionCell, map, filthSlime, Rand.Range(10, 12));

                    string letterLabel = "LetterLabelReplimatSpill".Translate();

                    string letterText = "LetterTextReplimatSpill".Translate(new object[]
                    {
                        currentTerminal.def.label
                    });

                    Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NegativeEvent, new TargetInfo(targetTerminal.Position, map));
                    return(true);
                }
            }
            else if (targetTerminal.def == ReplimatDef.ReplimatAnimalFeeder)
            {
                if (targetTerminal is Building_ReplimatAnimalFeeder currentAnimalFeeder && currentAnimalFeeder.HasEnoughFeedstockInHopperForIncident(volumeOfFeedstockToSpill))
                {
                    currentAnimalFeeder.powerComp.PowerNet.TryConsumeFeedstock(volumeOfFeedstockToSpill);
                    ThingDef filthSlime = ThingDefOf.Filth_Slime;
                    FilthMaker.TryMakeFilth(targetTerminal.InteractionCell, map, filthSlime, Rand.Range(10, 12));

                    string letterLabel = "LetterLabelReplimatSpill".Translate();

                    string letterText = "LetterTextReplimatSpill".Translate(new object[]
                    {
                        currentAnimalFeeder.def.label
                    });

                    Find.LetterStack.ReceiveLetter(letterLabel, letterText, LetterDefOf.NegativeEvent, new TargetInfo(targetTerminal.Position, map));
                    return(true);
                }
            }

            return(false);
        }