コード例 #1
0
        public override void Notify_PawnKilled()
        {
            base.Pawn.equipment.DestroyAllEquipment(DestroyMode.Vanish);
            base.Pawn.apparel.DestroyAll(DestroyMode.Vanish);
            bool flag = !base.Pawn.Spawned;

            if (!flag)
            {
                bool flag2 = this.Props.mote != null || this.Props.fleck != null;
                if (flag2)
                {
                    Vector3 pos = base.Pawn.DrawPos;
                    for (int i = 0; i < this.Props.moteCount; i++)
                    {
                        Vector2 offset = Rand.InsideUnitCircle * this.Props.moteOffsetRange.RandomInRange * (float)Rand.Sign;
                        Vector3 myPos  = new Vector3(pos.x + offset.x, pos.y, pos.z + offset.y);
                        bool    flag3  = this.Props.mote != null;
                        if (flag3)
                        {
                            MoteMaker.MakeStaticMote(myPos, base.Pawn.Map, this.Props.mote, 1f);
                        }
                        else
                        {
                            FleckMaker.Static(myPos, base.Pawn.Map, this.Props.fleck, 1f);
                        }
                    }
                }
                bool flag4 = this.Props.filth != null;
                if (flag4)
                {
                    FilthMaker.TryMakeFilth(base.Pawn.Position, base.Pawn.Map, this.Props.filth, this.Props.filthCount, FilthSourceFlags.None);
                }
                bool flag5 = this.Props.sound != null;
                if (flag5)
                {
                    this.Props.sound.PlayOneShot(SoundInfo.InMap(base.Pawn, MaintenanceType.None));
                }
            }
        }
コード例 #2
0
 public override void Impact_Override(Thing hitThing)
 {
     base.Impact_Override(hitThing);
     if (hitThing is Pawn p && p.BloodNeed() is Need_Blood bn)
     {
         GenExplosion.DoExplosion(p.PositionHeld, p.MapHeld, 3.9f, DamageDefOf.Flame, p);
         bn.AdjustBlood(-7);
         int num = GenRadial.NumCellsInRadius(3.9f);
         for (int i = 0; i < num; i++)
         {
             FilthMaker.TryMakeFilth(hitThing.PositionHeld + GenRadial.RadialPattern[i], hitThing.MapHeld, ((Pawn)hitThing).RaceProps.BloodDef, ((Pawn)hitThing).LabelIndefinite());
         }
         List <BodyPartRecord> parts = p.health.hediffSet.GetNotMissingParts().ToList().FindAll(x => x.depth == BodyPartDepth.Inside);
         for (int j = 0; j < 4; j++)
         {
             if (!p.Dead)
             {
                 p.TakeDamage(new DamageInfo(DamageDefOf.Burn, Rand.Range(8, 13), 1f, -1, Caster, parts.RandomElement()));
             }
         }
     }
 }
コード例 #3
0
        // Token: 0x06000019 RID: 25 RVA: 0x000025A8 File Offset: 0x000007A8
        public override DamageResult Apply(DamageInfo dinfo, Thing victim)
        {
            var pawn = victim as Pawn;

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

            var map          = victim.Map;
            var 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)
            {
                return(damageResult);
            }

            foreach (var intVec in victim.OccupiedRect())
            {
                FilthMaker.TryMakeFilth(intVec, map, ThingDefOf.Filth_Ash);
            }

            if (victim is not Plant plant || !victim.def.plant.IsTree || plant.LifeStage == PlantLifeStage.Sowing ||
                victim.def == ThingDefOf.BurnedTree)
            {
                return(damageResult);
            }

            var deadPlant = (DeadPlant)GenSpawn.Spawn(ThingDefOf.BurnedTree, victim.Position, map);

            deadPlant.Growth = plant.Growth;

            return(damageResult);
        }
コード例 #4
0
        public override void Resolve(ResolveParams rp)
        {
            Map         map         = BaseGen.globalSettings.map;
            TerrainGrid terrainGrid = map.terrainGrid;
            TerrainDef  terrainDef  = rp.floorDef ?? BaseGenUtility.RandomBasicFloorDef(rp.faction);
            bool?       floorOnlyIfTerrainSupports = rp.floorOnlyIfTerrainSupports;
            bool        flag = floorOnlyIfTerrainSupports.HasValue && floorOnlyIfTerrainSupports.Value;

            CellRect.CellRectIterator iterator = rp.rect.GetIterator();
            while (!iterator.Done())
            {
                if ((!rp.chanceToSkipFloor.HasValue || !Rand.Chance(rp.chanceToSkipFloor.Value)) && (!flag || GenConstruct.CanBuildOnTerrain(terrainDef, iterator.Current, map, Rot4.North)))
                {
                    terrainGrid.SetTerrain(iterator.Current, terrainDef);
                    if (rp.filthDef != null)
                    {
                        FilthMaker.MakeFilth(iterator.Current, map, rp.filthDef, (!rp.filthDensity.HasValue) ? 1 : Mathf.RoundToInt(rp.filthDensity.Value.RandomInRange));
                    }
                }
                iterator.MoveNext();
            }
        }
コード例 #5
0
        public static IEnumerable <Thing> GetProducts(Corpse corpse, Pawn butcher, float efficiency)
        {
            foreach (Thing product in corpse.InnerPawn.ButcherProducts(butcher, efficiency))
            {
                yield return(product);
            }

            if (corpse.InnerPawn.RaceProps.BloodDef != null)
            {
                FilthMaker.MakeFilth(butcher.Position, butcher.Map, corpse.InnerPawn.RaceProps.BloodDef, corpse.InnerPawn.LabelIndefinite(), 1);
            }

            if (corpse.InnerPawn.RaceProps.Humanlike)
            {
                butcher.needs.mood?.thoughts?.memories?.TryGainMemory(ThoughtDefOf.ButcheredHumanlikeCorpse, null);             // CHANGE/FIX HERE
                foreach (Pawn pawn in butcher.Map.mapPawns.SpawnedPawnsInFaction(butcher.Faction))
                {
                    pawn.needs.mood?.thoughts?.memories?.TryGainMemory(ThoughtDefOf.KnowButcheredHumanlikeCorpse);
                }
            }

            TaleRecorder.RecordTale(TaleDefOf.ButcheredHumanlikeCorpse, butcher);
        }
コード例 #6
0
        private static void DropRoofInCellPhaseTwo(IntVec3 c, Map map)
        {
            RoofDef roofDef = map.roofGrid.RoofAt(c);

            if (roofDef != null)
            {
                if (roofDef.filthLeaving != null)
                {
                    FilthMaker.MakeFilth(c, map, roofDef.filthLeaving);
                }
                if (roofDef.VanishOnCollapse)
                {
                    map.roofGrid.SetRoof(c, null);
                }
                CellRect bound = CellRect.CenteredOn(c, 2);
                foreach (Pawn item in from pawn in map.mapPawns.AllPawnsSpawned
                         where bound.Contains(pawn.Position)
                         select pawn)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CollapseDodged, item);
                }
            }
        }
コード例 #7
0
        public void Notify_PawnApproaching(Pawn pawn)
        {
            if (!pawn.IsPrisonerOfColony && (pawn.Faction == null || pawn.Faction.HostileTo(Faction.OfPlayer)))
            {
                return;
            }
            if (pawn.Drafted || pawn.health.hediffSet.BleedRateTotal > 0.01)
            {
                return;
            }
            if (pawn.CurJob != null && (pawn.CurJobDef == JobDefOf.Flee || pawn.CurJobDef == JobDefOf.FleeAndCower || pawn.CurJobDef == JobDefOf.TendPatient || pawn.CurJobDef.driverClass == typeof(JobDriver_TakeToBed)))
            {
                return;
            }
            List <Filth> carriedFilth = (List <Filth>)carriedFilthList.GetValue(pawn.filth);

            if (!carriedFilth.NullOrEmpty())
            {
                Filth filth = carriedFilth.RandomElement();
                FilthMaker.TryMakeFilth(Position, Map, filth.def, filth.sources);
                carriedFilthList.SetValue(pawn.filth, new List <Filth>());
            }
        }
コード例 #8
0
        public override DamageWorker.DamageResult Apply(DamageInfo dinfo, Thing victim)
        {
            Pawn attacker = dinfo.Instigator as Pawn;

            if (attacker != null)
            {
                attacker.needs.food.CurLevel += 0.3f;
            }
            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 c in victim.OccupiedRect())
                {
                    FilthMaker.TryMakeFilth(c, map, ThingDefOf.Filth_Ash, 1, FilthSourceFlags.None);
                }
                Plant plant = victim as Plant;
                if (plant != null && 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);
        }
        public static IEnumerable <Thing> Postfix(IEnumerable <Thing> entries, Corpse __instance, Pawn butcher)
        {
            RotStage stage = __instance.GetRotStage();

            foreach (Thing entry in entries)
            {
                if (stage != RotStage.Fresh)
                {
                    CompRottable comp = entry.TryGetComp <CompRottable>();

                    if (entry.GetStatValue(StatDefOf.DeteriorationRate) > 0.5)
                    {
                        entry.Destroy();
                        continue;
                    }
                    else if (comp != null)
                    {
                        if ((stage == RotStage.Dessicated) || comp.PropsRot.rotDestroys)
                        {
                            entry.Destroy();
                            continue;
                        }
                        else
                        {
                            comp.RotImmediately();
                        }
                    }
                }
                yield return(entry);
            }

            if (stage == RotStage.Rotting)
            {
                butcher.needs.mood.thoughts.memories.TryGainMemory(MyDefOf.LuluButcherRotten_ButcheredRotten);
                FilthMaker.TryMakeFilth(butcher.Position, butcher.Map, ThingDefOf.Filth_CorpseBile, __instance.InnerPawn.LabelIndefinite());
            }
        }
コード例 #10
0
        private bool ResolveTransformations()
        {
            if (!hadTransformationChance)
            {
                hadTransformationChance = true;
                if (Rand.Value <= RESettings.MUTATION_CHANCE)
                {
                    var curLoc   = this.PositionHeld;
                    var curMap   = this.MapHeld;
                    var zFaction = Find.FactionManager.FirstFactionOfDef(FactionDef.Named("RE_Zombies"));

                    HediffDef   zHDef;
                    PawnKindDef zKind = ResolveTransformationKind(out zHDef);

                    Pawn newThing;
                    if (zKind.defName != "RE_CrimsonHeadKind")
                    {
                        this.Destroy();
                        FilthMaker.TryMakeFilth(curLoc, curMap, ThingDefOf.Filth_Blood, Rand.Range(5, 8));
                        newThing = PawnGenerator.GeneratePawn(zKind, zFaction);
                    }
                    else
                    {
                        //The function here actually destroys the zombie
                        var facName = this?.Faction?.def?.defName ?? "RE_Zombies";
                        newThing = ZombieUtility.CreateZombieAtSourcePawnLocation(this, "RE_CrimsonHeadKind", facName);
                    }

                    HealthUtility.AdjustSeverity(newThing, zHDef, 1.0f);
                    GenSpawn.Spawn(newThing, curLoc, curMap);

                    ((Zombie)newThing).hadTransformationChance = true;
                    return(true);
                }
            }
            return(false);
        }
コード例 #11
0
        public void HatchFromPawn(Pawn newPawn)
        {
            if (newPawn is Alien alien && alien.def == PurpleIvyDefOf.Genny_ParasiteOmega)
            {
                alien.canHaul = false;
            }
            var host = (Pawn)this.parent;

            host.TakeDamage(new DamageInfo(DamageDefOf.SurgicalCut, 25f));
            if (host.Dead)
            {
                var corpse       = (Corpse)this.parent.ParentHolder;
                var compRottable = corpse.TryGetComp <CompRottable>();
                if (compRottable != null && compRottable.Stage < RotStage.Dessicated)
                {
                    compRottable.RotProgress += this.Props.rotProgressPerSpawn.RandomInRange;
                    FilthMaker.TryMakeFilth(corpse.Position, corpse.Map, corpse.InnerPawn.def.race.BloodDef);
                }
                GenSpawn.Spawn(newPawn, corpse.Position, corpse.Map);
            }
            else if (this.Props.IncubationData.deathChance >= Rand.RangeInclusive(0, 100))
            {
                this.parent.Kill();
                var corpse = (Corpse)this.parent.ParentHolder;
                Log.Message("3 Adding infected comp to " + corpse);
                corpse.AllComps.Add(this);
                this.parent.AllComps.Remove(this);
                FilthMaker.TryMakeFilth(corpse.Position, corpse.Map, corpse.InnerPawn.def.race.BloodDef);
                GenSpawn.Spawn(newPawn, corpse.Position, corpse.Map);
            }
            else
            {
                FilthMaker.TryMakeFilth(host.Position, host.Map, host.def.race.BloodDef);
                GenSpawn.Spawn(newPawn, host.Position, host.Map);
            }
        }
コード例 #12
0
ファイル: Harvest.cs プロジェクト: emipa606/AutopsyTable
    public static bool Prefix(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(true);
        }

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

        var table = butcher.CurJob.GetTarget(TargetIndex.A).Thing as Building_WorkTable;

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

        return(false);
    }
コード例 #13
0
        private void Impact()
        {
            Cthulhu.Utility.DebugReport("Impacted Called");
            for (int i = 0; i < 6; i++)
            {
                Vector3 loc = base.Position.ToVector3Shifted() + Gen.RandomHorizontalVector(1f);
                MoteMaker.ThrowDustPuff(loc, base.Map, 1.2f);
            }
            MoteMaker.ThrowLightningGlow(base.Position.ToVector3Shifted(), base.Map, 2f);
            PawnFlyersLanded pawnFlyerLanded = (PawnFlyersLanded)ThingMaker.MakeThing(PawnFlyerDef.landedDef, null);

            pawnFlyerLanded.pawnFlyer = this.pawnFlyer;
            pawnFlyerLanded.Contents  = this.contents;
            if (!pawnFlyerLanded.Contents.innerContainer.Contains(this.pawnFlyer))
            {
                pawnFlyerLanded.Contents.innerContainer.TryAdd(this.pawnFlyer);
            }
            GenSpawn.Spawn(pawnFlyerLanded, base.Position, base.Map, base.Rotation);
            RoofDef roof = base.Position.GetRoof(base.Map);

            if (roof != null)
            {
                if (!roof.soundPunchThrough.NullOrUndefined())
                {
                    roof.soundPunchThrough.PlayOneShot(new TargetInfo(base.Position, base.Map, false));
                }
                if (roof.filthLeaving != null)
                {
                    for (int j = 0; j < 3; j++)
                    {
                        FilthMaker.TryMakeFilth(base.Position, base.Map, roof.filthLeaving, 1);
                    }
                }
            }
            this.Destroy(DestroyMode.Vanish);
        }
コード例 #14
0
        // Token: 0x06000019 RID: 25 RVA: 0x000025A8 File Offset: 0x000007A8
        public override DamageWorker.DamageResult Apply(DamageInfo dinfo, Thing victim)
        {
            Pawn pawn = victim as Pawn;
            bool flag = pawn != null && pawn.Faction == Faction.OfPlayer;

            if (flag)
            {
                Find.TickManager.slower.SignalForceNormalSpeedShort();
            }
            Map map = victim.Map;

            DamageWorker.DamageResult damageResult = base.Apply(dinfo, victim);
            bool flag2 = !damageResult.deflected && !dinfo.InstantPermanentInjury;

            if (flag2)
            {
                victim.TryAttachFire(Rand.Range(0.15f, 0.25f));
            }
            bool flag3 = victim.Destroyed && map != null && pawn == null;

            if (flag3)
            {
                foreach (IntVec3 intVec in victim.OccupiedRect())
                {
                    FilthMaker.TryMakeFilth(intVec, map, ThingDefOf.Filth_Ash, 1);
                }
                Plant plant = victim as Plant;
                bool  flag4 = plant != null && victim.def.plant.IsTree && plant.LifeStage != PlantLifeStage.Sowing && victim.def != ThingDefOf.BurnedTree;
                if (flag4)
                {
                    DeadPlant deadPlant = (DeadPlant)GenSpawn.Spawn(ThingDefOf.BurnedTree, victim.Position, map, WipeMode.Vanish);
                    deadPlant.Growth = plant.Growth;
                }
            }
            return(damageResult);
        }
コード例 #15
0
        public override void GenerateForces(Map map, ResolveParams rp, ScatterOptions options)
        {
            Debug.Log(Debug.ForceGen, "Animal forces generation");
            CellRect rect = rp.rect;

            /*if (rect.minX < 15 || rect.minZ < 15 || rect.maxX > map.Size.x - 15 || rect.maxZ > map.Size.z - 15) {
             *  return; //do not add enemies if we're on the map edge
             * }
             *
             * if (!CellFinder.TryFindRandomCellInsideWith(rect, (IntVec3 x) => x.Standable(map) && options.roomMap[x.x - rect.BottomLeft.x, x.z - rect.BottomLeft.z] > 1, out IntVec3 testCell)) {
             *  return; //interrupt if there are no closed cells available
             * }*/

            PawnKindDef pawnKindDef = null;


            pawnKindDef = map.Biome.AllWildAnimals.RandomElementByWeight((PawnKindDef def) => (def.RaceProps.foodType == FoodTypeFlags.CarnivoreAnimal || def.RaceProps.foodType == FoodTypeFlags.OmnivoreAnimal) ? 1 : 0);

            float powerMax = (float)Math.Sqrt(options.uncoveredCost / 10 * (rect.Area / 30.0f));

            Debug.Log(Debug.ForceGen, "Unscaled power is {0} based on cost of {1} and area of {2}", powerMax, options.uncoveredCost, rect.Area);
            powerMax = ScalePointsToDifficulty(powerMax);
            float powerThreshold = (Math.Abs(Rand.Gaussian(0.5f, 1)) * powerMax) + 1;

            float cumulativePower = 0;

            Faction faction = Faction.OfAncientsHostile;

            Lord lord = LordMaker.MakeNewLord(lordJob: new LordJob_DefendPoint(rect.CenterCell), faction: faction, map: map, startingPawns: null);
            int  tile = map.Tile;

            while (cumulativePower <= powerThreshold)
            {
                PawnKindDef           currentPawnKindDef = pawnKindDef;
                PawnGenerationRequest request            =
                    new PawnGenerationRequest(currentPawnKindDef, faction, PawnGenerationContext.NonPlayer, tile, true, false, false, //allowDead is last
                                              false, true, true, 1f,
                                              false, true, true, true,
                                              false, false, false,
                                              true, 0, null, 1, null, null, null,
                                              null, null, null, null);

                IntVec3 cell = IntVec3.Invalid;
                if (!CellFinder.TryFindRandomCellInsideWith(rect, (IntVec3 x) => x.Standable(map) && options.roomMap[x.x - rect.minX, x.z - rect.minZ] > 1, out cell))
                {
                    CellFinder.TryFindRandomSpawnCellForPawnNear(rect.CenterCell, map, out cell);
                }

                if (cell != IntVec3.Invalid)
                {
                    Pawn pawn = PawnGenerator.GeneratePawn(request);

                    FilthMaker.TryMakeFilth(cell, map, ThingDefOf.Filth_Blood, 5);
                    GenSpawn.Spawn(pawn, cell, map, WipeMode.Vanish);

                    lord.AddPawn(pawn);
                    cumulativePower += pawn.kindDef.combatPower;
                }
                else
                {
                    break; //no more suitable cells
                }
            }
        }
コード例 #16
0
        protected virtual void Impact(Thing hitThing)
        {
            var ignoredThings = new List <Thing>();

            //Spawn things from preExplosionSpawnThingDef != null
            if (Position.IsValid &&
                def.projectile.preExplosionSpawnChance > 0 &&
                def.projectile.preExplosionSpawnThingDef != null &&
                (Controller.settings.EnableAmmoSystem || !(def.projectile.preExplosionSpawnThingDef is AmmoDef)) &&
                Rand.Value < def.projectile.preExplosionSpawnChance)
            {
                var thingDef = def.projectile.preExplosionSpawnThingDef;

                if (thingDef.IsFilth && Position.Walkable(Map))
                {
                    FilthMaker.TryMakeFilth(Position, Map, thingDef);
                }
                else if (Controller.settings.ReuseNeolithicProjectiles)
                {
                    var reusableAmmo = ThingMaker.MakeThing(thingDef);
                    reusableAmmo.stackCount = 1;
                    reusableAmmo.SetForbidden(true, false);
                    GenPlace.TryPlaceThing(reusableAmmo, Position, Map, ThingPlaceMode.Near);
                    LessonAutoActivator.TeachOpportunity(CE_ConceptDefOf.CE_ReusableNeolithicProjectiles, reusableAmmo, OpportunityType.GoodToKnow);
                    ignoredThings.Add(reusableAmmo);
                }
            }

            var explodePos = hitThing?.DrawPos ?? ExactPosition;

            if (!explodePos.ToIntVec3().IsValid)
            {
                Destroy();
                return;
            }

            var explodingComp = this.TryGetComp <CompExplosiveCE>();

            if (explodingComp == null)
            {
                this.TryGetComp <CompFragments>()?.Throw(explodePos, Map, launcher);
            }

            //If the comp exists, it'll already call CompFragments
            if (explodingComp != null || def.projectile.explosionRadius > 0)
            {
                //Handle anything explosive

                if (hitThing is Pawn && (hitThing as Pawn).Dead)
                {
                    ignoredThings.Add((hitThing as Pawn).Corpse);
                }

                var suppressThings = new List <Pawn>();
                var dir            = new float?(origin.AngleTo(Vec2Position()));

                // Opt-out for things without explosionRadius
                if (def.projectile.explosionRadius > 0)
                {
                    GenExplosionCE.DoExplosion(explodePos.ToIntVec3(), Map, def.projectile.explosionRadius,
                                               def.projectile.damageDef, launcher, def.projectile.GetDamageAmount(1), def.projectile.GetDamageAmount(1) * 0.1f,
                                               def.projectile.soundExplode, equipmentDef,
                                               def, null, def.projectile.postExplosionSpawnThingDef, def.projectile.postExplosionSpawnChance, def.projectile.postExplosionSpawnThingCount,
                                               def.projectile.applyDamageToExplosionCellsNeighbors, def.projectile.preExplosionSpawnThingDef, def.projectile.preExplosionSpawnChance,
                                               def.projectile.preExplosionSpawnThingCount, def.projectile.explosionChanceToStartFire, def.projectile.explosionDamageFalloff,
                                               dir, ignoredThings, explodePos.y);

                    // Apply suppression around impact area
                    if (explodePos.y < SuppressionRadius)
                    {
                        suppressThings.AddRange(GenRadial.RadialDistinctThingsAround(explodePos.ToIntVec3(), Map, SuppressionRadius + def.projectile.explosionRadius, true)
                                                .Where(x => x is Pawn).Select(x => x as Pawn));
                    }
                }

                if (explodingComp != null)
                {
                    explodingComp.Explode(this, explodePos, Map, 1f, dir, ignoredThings);

                    if (explodePos.y < SuppressionRadius)
                    {
                        suppressThings.AddRange(GenRadial.RadialDistinctThingsAround(explodePos.ToIntVec3(), Map, SuppressionRadius + (explodingComp.props as CompProperties_ExplosiveCE).explosiveRadius, true)
                                                .Where(x => x is Pawn).Select(x => x as Pawn));
                    }
                }

                foreach (var thing in suppressThings)
                {
                    ApplySuppression(thing as Pawn);
                }
            }

            Destroy();
        }
コード例 #17
0
        public void Hatch()
        {
            Tools.Warn("hatcheeFaction == null", hatcheeFaction == null && MyDebug);
            Tools.Warn("hatcheeParent == null", hatcheeParent == null && MyDebug);
            Tools.Warn("otherParent == null", otherParent == null && MyDebug);

            PawnGenerationContext pGenContext = PawnGenerationContext.NonPlayer;

            /*
             * bool TryingToSpawnMechanoid = hatcheePawnKind.RaceProps.IsMechanoid;
             * if (TryingToSpawnMechanoid) hatcheeFaction = Faction.OfAncients;
             */

            try
            {
                //PawnGenerationRequest request = new PawnGenerationRequest(
                //    Props.hatcherPawn, hatcheeFaction, PawnGenerationContext.NonPlayer, -1, forceGenerateNewPawn: false, newborn: true);

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

                for (int i = 0; i < parent.stackCount; i++)
                {
                    bool newBorn = Rand.Chance(Props.newBornChance);
                    if (SetPawnKind())
                    {
                        Tools.Warn("SetPawnKind: " + hatcheePawnKind.label, MyDebug);
                    }
                    else
                    {
                        continue;
                    }

                    PawnGenerationRequest request;

                    /*
                     * if (TryingToSpawnMechanoid)
                     * {
                     *  request = new PawnGenerationRequest(
                     *      kind: hatcheePawnKind, faction: hatcheeFaction, context: pGenContext,
                     *      tile: -1, forceGenerateNewPawn: false, newborn: newBorn, allowDead: false,
                     *      allowDowned: false, canGeneratePawnRelations: false, mustBeCapableOfViolence: true, colonistRelationChanceFactor: 0,
                     *      forceAddFreeWarmLayerIfNeeded: false, allowGay: false
                     *      );
                     *   would require to set faction
                     * }
                     * else
                     * {
                     */
                    request = new PawnGenerationRequest(
                        kind: hatcheePawnKind, faction: hatcheeFaction, context: pGenContext, tile: -1,
                        forceGenerateNewPawn: false, newborn: newBorn
                        );

                    Pawn pawn = PawnGenerator.GeneratePawn(request);
                    if (parent.MyTrySpawnHatchedOrBornPawn(pawn))
                    {
                        if (pawn == null)
                        {
                            continue;
                        }

                        if (hatcheeParent != null)
                        {
                            pawn.InheritParentSettings(hatcheeParent, hatcheeFaction);
                            pawn.AddParentRelations(hatcheeParent);
                        }
                        pawn.AddOtherParentRelations(hatcheeParent, otherParent);

                        if (parent.Spawned)
                        {
                            FilthMaker.TryMakeFilth(parent.Position, parent.Map, ThingDefOf.Filth_AmnioticFluid);
                        }

                        if (Rand.Chance(Props.manhunterChance))
                        {
                            pawn.MakeManhunter(MyDebug);
                        }
                    }
                    else
                    {
                        Find.WorldPawns.PassToWorld(pawn, PawnDiscardDecideMode.Discard);
                    }
                }
            }
            finally
            {
                parent.Destroy();
            }
        }
コード例 #18
0
        //Handles the spawning of pawns
        public override void GiveBirth()
        {
            Pawn mother = pawn;

            if (mother == null)
            {
                return;
            }

            if (!babies.NullOrEmpty())
            {
                foreach (Pawn baby in babies)
                {
                    baby.Discard(true);
                }
            }

            Faction spawn_faction = null;

            if (!is_hacked)
            {
                spawn_faction = Faction.OfMechanoids;
            }

            PawnGenerationRequest request = new PawnGenerationRequest(
                kind: PawnKindDef.Named("Mech_Scyther"),
                faction: spawn_faction,
                forceGenerateNewPawn: true,
                newborn: true
                );

            Pawn mech = PawnGenerator.GeneratePawn(request);

            PawnUtility.TrySpawnHatchedOrBornPawn(mech, mother);
            if (!is_hacked)
            {
                LordJob_MechanoidsDefend lordJob = new LordJob_MechanoidsDefend();
                Lord lord = LordMaker.MakeNewLord(mech.Faction, lordJob, mech.Map);
                lord.AddPawn(mech);
            }
            FilthMaker.TryMakeFilth(mech.PositionHeld, mech.MapHeld, mother.RaceProps.BloodDef, mother.LabelIndefinite());

            IEnumerable <BodyPartRecord> source = from x in mother.health.hediffSet.GetNotMissingParts() where
                                                  x.IsInGroup(BodyPartGroupDefOf.Torso) &&
                                                  !x.IsCorePart
                                                  //&& x.groups.Contains(BodyPartGroupDefOf.Torso)
                                                  //&& x.depth == BodyPartDepth.Inside
                                                  //&& x.height == BodyPartHeight.Bottom
                                                  //someday include depth filter
                                                  //so it doesnt cut out external organs (breasts)?
                                                  //vag  is genital part and genital is external
                                                  //anal is internal
                                                  //make sep part of vag?
                                                  //&& x.depth == BodyPartDepth.Inside
                                                  select x;

            if (source.Any())
            {
                foreach (BodyPartRecord part in source)
                {
                    mother.health.DropBloodFilth();
                }
                foreach (BodyPartRecord part in source)
                {
                    Hediff_MissingPart hediff_MissingPart = (Hediff_MissingPart)HediffMaker.MakeHediff(HediffDefOf.MissingBodyPart, mother, part);
                    hediff_MissingPart.lastInjury = HediffDefOf.Cut;
                    hediff_MissingPart.IsFresh    = true;
                    mother.health.AddHediff(hediff_MissingPart);
                }
            }
            mother.health.RemoveHediff(this);
        }
コード例 #19
0
        public override void Tick()
        {
            if (!base.Spawned)
            {
                return;
            }
            sustainer.Maintain();
            Vector3    vector      = base.Position.ToVector3Shifted();
            TargetInfo localTarget = new TargetInfo(this);

            Rand.PushState();
            if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors), null, null, out IntVec3 result) && !filthTypes.NullOrEmpty())
            {
                FilthMaker.TryMakeFilth(result, base.Map, filthTypes.RandomElement());
            }
            if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
            {
                Vector3 loc = new Vector3(vector.x, 0f, vector.z);
                loc.y = AltitudeLayer.MoteOverhead.AltitudeFor();
                MoteMaker.ThrowDustPuffThick(loc, base.Map, Rand.Range(1.5f, 3f), Ext.dustColor ?? new Color(1f, 1f, 1f, 2.5f));
                if (Ext.thowSparksinDust)
                {
                    if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 1f, 0.25f))
                    {
                        MoteMaker.ThrowMicroSparks(loc, base.Map);
                    }
                }
            }
            if (Ext.effecter != null)
            {
                if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 0.5f, 0.25f))
                {
                    if (this.Effecter == null && Ext.effecter != null)
                    {
                        this.Effecter = new Effecter(Ext.effecter);
                    }
                    if (Effecter != null)
                    {
                        Effecter.EffectTick(localTarget, localTarget);
                    }
                    else
                    {
                        this.Effecter.EffectTick(localTarget, localTarget);
                    }
                }
            }
            Rand.PopState();
            if (secondarySpawnTick > Find.TickManager.TicksGame)
            {
                return;
            }
            if (this.Effecter != null)
            {
                this.Effecter.Cleanup();
            }
            sustainer.End();
            Map     map      = base.Map;
            IntVec3 position = base.Position;

            Destroy();
            if (Ext.strikespreexplode)
            {
                FireEvent(map, position);
            }
            if (Ext.explodesprespawn)
            {
                GenExplosion.DoExplosion(position, map, Ext.blastradius, Ext.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
            }
            Hive obj = null;

            if (spawnHive)
            {
                obj = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(this.Ext.HiveDef), position, map);
                obj.SetFaction(SpawnedFaction);
                obj.questTags = questTags;
                foreach (CompSpawner comp in obj.GetComps <CompSpawner>())
                {
                    if (comp.PropsSpawner.thingToSpawn == RimWorld.ThingDefOf.InsectJelly)
                    {
                        comp.TryDoSpawn();
                        break;
                    }
                }
            }
            List <Pawn> list = new List <Pawn>();

            if ((initialPoints > 0f))
            {
                initialPoints = Mathf.Max(initialPoints, this.Ext.HiveDef.GetCompProperties <CompProperties_SpawnerPawn>().spawnablePawnKinds.Min((PawnGenOption x) => x.Cost));
                float         pointsLeft = initialPoints;
                int           num        = 0;
                PawnGenOption result2;
                for (; pointsLeft > 0f; pointsLeft -= result2.Cost)
                {
                    num++;
                    if (num > 1000)
                    {
                        Log.Error("Too many iterations.");
                        break;
                    }
                    if (!this.Ext.HiveDef.GetCompProperties <CompProperties_SpawnerPawn>().spawnablePawnKinds.Where((PawnGenOption x) => x.Cost <= pointsLeft).TryRandomElementByWeight(x => x.selectionWeight, out result2))
                    {
                        break;
                    }
                    Pawn pawn = PawnGenerator.GeneratePawn(result2.kind, SpawnedFaction);
                    GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2), map);
                    pawn.mindState.spawnedByInfestationThingComp = spawnedByInfestationThingComp;
                    list.Add(pawn);
                }
            }
            if (list.Any())
            {
                this.MakeLord(lordJobType, list);
            }
        }
コード例 #20
0
        private Toil HaveFunWithDemons()
        {
            Toil toil = new Toil();

            this.pawn.GetCompFace(out CompFace compFace);

            toil.initAction = delegate
            {
                // this.ticksLeft = Rand.Range(300, 900);
                this.ticksLeft = Rand.Range(450, 1200);
                int     num2 = 0;
                IntVec3 c;
                while (true)
                {
                    c = this.pawn.Position + GenAdj.AdjacentCellsAndInside[Rand.Range(0, 9)];
                    num2++;
                    if (num2 > 12)
                    {
                        c = this.pawn.Position;
                        break;
                    }

                    if (c.InBounds(this.pawn.Map) && c.Standable(this.pawn.Map))
                    {
                        break;
                    }
                }

                this.job.targetB = c;
                this.pawn.pather.StopDead();

                DefDatabase <SoundDef> .GetNamed("Pawn_Cat_Angry")
                .PlayOneShot(new TargetInfo(this.pawn.Position, this.pawn.Map));                      // GenExplosion.DoExplosion(

                // this.pawn.Position,
                // this.pawn.Map,
                // 2,
                // DamageDefOf.Smoke,
                // null,
                // 0,
                // DefDatabase<SoundDef>.GetNamed("Explosion_Smoke"));
                // for (int i = 0; i < 2; i++)
                // {
                // var loc = this.pawn.Position.ToVector3Shifted();
                // var map = this.pawn.Map;
                // MoteMaker.ThrowSmoke(loc, map, 1f);
                // MoteMaker.ThrowMicroSparks(loc, map);
                // MoteMaker.ThrowLightningGlow(loc, map, 1f);
                // }
            };

            int accellerator = 25;

            toil.tickAction = delegate
            {
                if (this.ticksLeft % 60 == 0)
                {
                    // MoteMaker.ThrowFireGlow(this.pawn.Position, this.pawn.Map, 0.1f);
                }

                // if (this.ticksLeft % 45 == 0)
                // {
                // MoteMaker.ThrowHeatGlow(this.pawn.Position, this.pawn.Map, 0.3f);
                // }
                if (this.ticksLeft % accellerator == 0)
                {
                    compFace.HeadRotator.RotateRandomly();

                    // MoteMaker.ThrowSmoke(this.pawn.Position.ToVector3(), this.pawn.Map, 0.2f);
                    if (accellerator > 20)
                    {
                        accellerator--;
                    }
                    else if (accellerator < 37)
                    {
                        accellerator++;
                    }
                }

                if (this.ticksLeft % 150 == 149)
                {
                    DefDatabase <SoundDef> .GetNamed("Pawn_Cat_Angry")
                    .PlayOneShot(new TargetInfo(this.pawn.Position, this.pawn.Map));

                    FilthMaker.MakeFilth(this.job.targetA.Cell, this.Map,
                                         ThingDefOf.FilthVomit, this.pawn.LabelIndefinite());
                    if (this.pawn.needs.food.CurLevelPercentage > 0.10000000149011612)
                    {
                        this.pawn.needs.food.CurLevel -= (float)(this.pawn.needs.food.MaxLevel * 0.02);
                    }
                }

                if (this.ticksLeft % 50 == 0)
                {
                    FilthMaker.MakeFilth(this.pawn.Position.RandomAdjacentCell8Way(), this.Map,
                                         ThingDefOf.FilthVomit, this.pawn.LabelIndefinite());
                }

                this.ticksLeft--;
                if (this.ticksLeft <= 0)
                {
                    this.ReadyForNextToil();
                    TaleRecorder.RecordTale(TaleDefOf.Vomited, this.pawn);
                }
            };

            toil.AddFinishAction(compFace.HeadRotator.SetUnPossessed);

            toil.defaultCompleteMode = ToilCompleteMode.Never;
            return(toil);
        }
コード例 #21
0
 public void ButcherProducts(Corpse corpse)
 {
     if (corpse.InnerPawn != null)
     {
         if (corpse.InnerPawn.RaceProps.Humanlike)
         {
             IntVec3 pos = corpse.PositionHeld;
             if (corpse.InnerPawn.equipment != null)
             {
                 corpse.InnerPawn.equipment.DropAllEquipment(pos, true);
             }
             if (corpse.InnerPawn.apparel != null)
             {
                 corpse.InnerPawn.apparel.DropAll(pos, true);
             }
             if (corpse.InnerPawn.inventory != null)
             {
                 corpse.InnerPawn.inventory.DropAllNearPawn(pos, true);
             }
         }
         if (corpse.InnerPawn.RaceProps.meatDef != null)
         {
             int count = GenMath.RoundRandom(corpse.InnerPawn.GetStatValue(StatDefOf.MeatAmount, true));
             if (count > 0)
             {
                 Thing thing = ThingMaker.MakeThing(corpse.InnerPawn.RaceProps.meatDef, null);
                 thing.stackCount = count;
                 if (thing.stackCount >= 2)
                 {
                     RotStage rotStage = corpse.GetRotStage();
                     if (rotStage == RotStage.Rotting)
                     {
                         thing.stackCount = count / 2;
                     }
                 }
                 GenPlace.TryPlaceThing(thing, corpse.Position, corpse.Map, ThingPlaceMode.Direct, out Thing meat, null);
                 if (meat != null)
                 {
                     meat.SetForbidden(true);
                 }
             }
         }
         if (corpse.InnerPawn.RaceProps.leatherDef != null)
         {
             int count = GenMath.RoundRandom(corpse.InnerPawn.GetStatValue(StatDefOf.LeatherAmount, true));
             if (count > 0)
             {
                 Thing thing = ThingMaker.MakeThing(corpse.InnerPawn.RaceProps.leatherDef, null);
                 thing.stackCount = count;
                 if (thing.stackCount >= 2)
                 {
                     RotStage rotStage = corpse.GetRotStage();
                     if (rotStage == RotStage.Rotting)
                     {
                         thing.stackCount = count / 2;
                     }
                 }
                 GenPlace.TryPlaceThing(thing, corpse.Position, corpse.Map, ThingPlaceMode.Direct, out Thing leather, null);
                 if (leather != null)
                 {
                     leather.SetForbidden(true);
                 }
             }
         }
         if (corpse.InnerPawn.RaceProps.BloodDef != null)
         {
             FilthMaker.MakeFilth(corpse.Position, corpse.Map, corpse.InnerPawn.RaceProps.BloodDef, corpse.InnerPawn.LabelIndefinite(), 1);
         }
     }
 }
コード例 #22
0
        // Token: 0x06000001 RID: 1 RVA: 0x00002050 File Offset: 0x00000250
        internal static void GenerateMincho(Pawn pawn, Hediff hediff)
        {
            PawnGenerationRequest pawnGenerationRequest = new PawnGenerationRequest(
                MinchoDefOf.Mincho_Colonist,
                Faction.OfPlayer,
                (PawnGenerationContext)2,
                -1,
                false,
                false,
                false,
                false,
                false,
                false,
                0f,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                false,
                0,
                null,
                0, null, null, null, null, null, pawn.ageTracker.AgeBiologicalYearsFloat, pawn.ageTracker.AgeChronologicalYearsFloat, null, 0, null, null, null);

            for (int i = 0; i < 9; i++)
            {
                IntVec3 intVec = pawn.Position + GenRadial.RadialPattern[i];
                bool    flag   = GenGrid.InBounds(intVec, pawn.Map) && GridsUtility.GetRoom(pawn.Position, pawn.Map, (RegionType)6) == GridsUtility.GetRoom(intVec, pawn.Map, (RegionType)6);
                if (flag)
                {
                    FilthMaker.TryMakeFilth(pawn.Position, pawn.Map, MinchoDefOf.Mincho_Filth_BloodDef, GenText.LabelIndefinite(pawn), Rand.RangeInclusive(0, 4));
                }
            }
            Pawn pawn2 = PawnGenerator.GeneratePawn(pawnGenerationRequest);

            pawn2.Name = pawn.Name;



            if (pawn.IsColonist == true | pawn.IsColonistPlayerControlled == true)
            {
                foreach (KeyValuePair <string, Backstory> asd1 in BackstoryDatabase.allBackstories)
                {
                    if (asd1.Value.untranslatedTitle == "The first Mincho")
                    {
                        pawn2.story.childhood = asd1.Value;
                        break;
                    }
                    if (asd1.Value.untranslatedTitleFemale == "The first Mincho")
                    {
                        pawn2.story.childhood = asd1.Value;
                        break;
                    }
                }

                foreach (Pawn asd1 in pawn.relations.RelatedPawns)
                {
                    foreach (DirectPawnRelation asd2 in asd1.relations.DirectRelations)
                    {
                        asd1.relations.RemoveDirectRelation(asd2);
                    }
                    foreach (DirectPawnRelation asd2 in pawn.relations.DirectRelations)
                    {
                        pawn2.relations.AddDirectRelation(asd2.def, asd1);
                    }
                }


                //pawn2.story.childhood = BackstoryDatabase.allBackstories.ToList<KeyValuePair<string, Backstory>>().Find((KeyValuePair<string, Backstory> x) => x.Value.untranslatedTitle == "The first Mincho").Value;
                pawn2.skills.skills = pawn.skills.skills;
                foreach (Trait asd1 in pawn.story.traits.allTraits)
                {
                    if (asd1.def.ToString() == "Nudist")
                    {
                        pawn.story.traits.allTraits.Remove(asd1);
                    }
                }
                pawn2.story.traits.allTraits = pawn.story.traits.allTraits;
            }
            else
            {
                foreach (KeyValuePair <string, Backstory> asd1 in BackstoryDatabase.allBackstories)
                {
                    if (asd1.Value.untranslatedTitle == "Mincho poultice")
                    {
                        pawn2.story.childhood = asd1.Value;
                        break;
                    }
                    if (asd1.Value.untranslatedTitleFemale == "Mincho poultice")
                    {
                        pawn2.story.childhood = asd1.Value;
                        break;
                    }
                }
                //pawn2.story.childhood = BackstoryDatabase.allBackstories.ToList<KeyValuePair<string, Backstory>>().Find((KeyValuePair<string, Backstory> x) => x.Value.untranslatedTitle == "Mincho poultice").Value;
                pawn2.skills.skills = pawn.skills.skills;
                foreach (Trait asd1 in pawn.story.traits.allTraits)
                {
                    if (asd1.def.ToString() == "Nudist")
                    {
                        pawn.story.traits.allTraits.Remove(asd1);
                    }
                    foreach (TraitDegreeData asd2 in asd1.def.degreeDatas)
                    {
                        if (asd2.untranslatedLabel == "Nudist")
                        {
                            pawn.story.traits.allTraits.Remove(asd1);
                        }
                    }
                }
                pawn2.story.traits.allTraits = pawn.story.traits.allTraits;
            }
            pawn2.story.adulthood = null;


            /*
             * if (pawn.Faction != null)
             * {
             *      pawn.Faction.TryAffectGoodwillWith(Faction.OfPlayer, -40, true, true, TranslatorFormattedStringExtensions.Translate("MinchoTransform", pawn.Name.ToStringShort), null);
             * }
             */

            //pawn.health.RemoveHediff(hediff);
            Map map = pawn.Map;

            pawn.Kill(null);

            CompRottable comp = pawn.Corpse.GetComp <CompRottable>();

            if (comp != null)
            {
                comp.RotProgress = (float)(comp.TicksUntilRotAtCurrentTemp * 2);
            }


            //Messages.Message(TranslatorFormattedStringExtensions.Translate("MinchoTransform", pawn.Name.ToStringShort), MessageTypeDefOf.NegativeHealthEvent, true);
            pawn2.apparel.DestroyAll(0);
            GenSpawn.Spawn(pawn2, pawn.Position, map, 0);
            //SoundStarter.PlayOneShot(MinchoDefOf.Pawn_Mincho_Death, SoundInfo.InMap(pawn, 0));
            MinchoGenerator.MakeWildMan(pawn2, pawn);
            Find.TickManager.Pause();
        }
コード例 #23
0
        public void SpawnBug(Faction faction)
        {
            Egg         egg     = parent as Egg;
            Queen       queen   = egg.eggLayer;
            PawnKindDef kindDef = null;
            int         random  = Rand.Range(1, 50);
            int         random2 = Rand.Range(1, 3);

            switch (random)
            {
            case int n when n <= 26:
                kindDef = HiveUtility.GetFactionKindDef(PawnKindDef.Named("BI_Megascarab_Brown"), faction);
                break;

            case int n when n >= 27 && n <= 40:
                kindDef = HiveUtility.GetFactionKindDef(PawnKindDef.Named("BI_Spelopede_Brown"), faction);
                break;

            case int n when n >= 41 && n <= 48:
                kindDef = HiveUtility.GetFactionKindDef(PawnKindDef.Named("BI_Megaspider_Brown"), faction);
                break;

            case int n when n >= 49 && n <= 50:
                kindDef = HiveUtility.GetFactionKindDef(PawnKindDef.Named("BI_Queen_Brown"), faction);
                break;
            }
            if (kindDef != null)
            {
                PawnGenerationRequest request = new PawnGenerationRequest(kindDef, faction, PawnGenerationContext.NonPlayer, -1, true, true, false, false, false, false, 1f, false, false, true, false, false, false, false, null, null, null, null, null, null, null, null);
                Pawn pawn = PawnGenerator.GeneratePawn(request);
                if (kindDef.defName.Contains("BI_Queen"))
                {
                    IntVec3 loc;
                    if (InfestationCellFinder.TryFindCell(out loc, egg.Map))
                    {
                        Queen queen2 = pawn as Queen;
                        if (queen2 != null)
                        {
                            queen2.hiveLocation = loc;
                        }
                    }
                }
                GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(egg.Position, egg.Map, 2, null), egg.Map);
                Lord lord = null;
                if (queen != null && !queen.Dead)
                {
                    lord = queen.Lord;
                    queen.spawnedEggs.Remove(egg);
                    if (!kindDef.defName.Contains("BI_Queen"))
                    {
                        queen.spawnedInsects.Add(pawn);
                    }
                }
                if (queen == null || queen.Dead || lord == null)
                {
                    lord = CreateNewLord(faction);
                }
                if (!kindDef.defName.Contains("BI_Queen"))
                {
                    lord.AddPawn(pawn);
                }
                FilthMaker.MakeFilth(egg.Position, egg.Map, ThingDefOf.Filth_Slime, 12);
                SoundDefOf.Hive_Spawn.PlayOneShot(egg);
                egg.Destroy(DestroyMode.Vanish);
            }
        }
コード例 #24
0
        //
        #endregion Properties

        public override void Tick()
        {
            base.Tick();

            ++this.currentTick;

            if (this.currentTick == 60)
            {
                this.currentTick = 0;

                float prob = this.amountOfFilth / 150;
                float roll = Rand.Value;

                if (roll < prob && this.amountOfFilth > 0)
                {
                    FilthMaker.TryMakeFilth(this.Position, base.Map, ThingDefOf.Filth_Slime);
                    this.DecrementFilth();
                }
            }

            if (digesting == null)
            {
                if (currentDump == null)
                {
                    if (!base.Map.zoneManager.AllZones.NullOrEmpty())
                    {
                        List <Zone> zones        = base.Map.zoneManager.AllZones;
                        float       nextDistance = 999999f;

                        foreach (Zone z in zones)
                        {
                            if (z.label.Split(' ') [0].Equals("Dumping"))
                            {
                                if (nextDistance > this.Position.DistanceTo(z.cells [0]))
                                {
                                    this.currentDump = z;
                                }
                            }
                        }
                    }

                    if (this.currentDump != null)
                    {
                        this.jobs.ClearQueuedJobs();
                        this.pather.StartPath(new LocalTargetInfo(this.currentDump.cells [0]), Verse.AI.PathEndMode.OnCell);
                    }
                }
                else
                {
                    if (this.Position.AdjacentTo8WayOrInside(this.currentDump.cells [0]))
                    {
                        Thing toBeDigested = null;

                        IEnumerable <Thing> ts = this.currentDump.AllContainedThings;

                        foreach (Thing t in ts)
                        {
                            if (t is Pokemon_Abstract_Slimes && t.Faction == null)
                            {
                                Pokemon_Abstract_Slimes g = (Pokemon_Abstract_Slimes)t;
                                for (int gi = (int)g.amountOfFilth; gi >= 0; gi--)
                                {
                                    this.IncrementFilth();
                                }
                                t.DeSpawn();
                                this.IncrementFilth();
                            }
                            else if (t != null && !(t is Pawn))
                            {
                                toBeDigested = t;
                                break;
                            }
                        }

                        this.digestingTicks = 15000L;
                        toBeDigested.DeSpawn();
                        this.currentDump = null;
                        this.digesting   = toBeDigested;
                    }
                    else if (this.pather.Destination != new LocalTargetInfo(this.currentDump.cells [0]))
                    {
                        this.jobs.ClearQueuedJobs();
                        this.pather.StartPath(new LocalTargetInfo(this.currentDump.cells [0]), Verse.AI.PathEndMode.OnCell);
                    }
                }
            }
            else
            {
                --this.digestingTicks;

                if (this.digestingTicks <= 0)
                {
                    ++this.amountOfFilth;
                    this.digesting = null;
                }
            }
        }
コード例 #25
0
        //
        // Methods
        //
        public void DoBirthSpawn(Pawn mother, Pawn father, float chance_successful = 1.0f)
        {
            if (mother == null)
            {
                Log.Error("No mother defined");
                return;
            }
            if (father == null)
            {
                Log.Warning("No father defined");
            }

            float birthing_quality = mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("GivingBirth")).TryGetComp <HediffComp_TendDuration> ().tendQuality;

            mother.health.AddHediff(HediffDef.Named("PostPregnancy"), null, null);
            mother.health.AddHediff(HediffDef.Named("Lactating"), ChildrenUtility.GetPawnBodyPart(pawn, "Torso"), null);

            int num = (mother.RaceProps.litterSizeCurve == null) ? 1 : Mathf.RoundToInt(Rand.ByCurve(mother.RaceProps.litterSizeCurve, 300));

            if (num < 1)
            {
                num = 1;
            }

            // Make sure the pawn looks like mommy and daddy
            float skin_whiteness = Rand.Range(0, 1);
            // Pool of "genetic traits" the baby can inherit
            List <Trait> traitpool = new List <Trait>();

            if (mother.RaceProps.Humanlike)
            {
                // Add mom's traits to the pool
                foreach (Trait momtrait in mother.story.traits.allTraits)
                {
                    traitpool.Add(momtrait);
                }
                if (father != null)
                {
                    // Add dad's traits to the pool
                    foreach (Trait dadtrait in father.story.traits.allTraits)
                    {
                        traitpool.Add(dadtrait);
                    }
                    // Blend skin colour between mom and dad
                    skin_whiteness = Rand.Range(mother.story.melanin, father.story.melanin);
                }
                else
                {
                    // If dad doesn't exist, just use mom's skin colour
                    skin_whiteness = mother.story.melanin;
                }

                // Clear out any traits that aren't genetic from the list
                if (traitpool.Count > 0)
                {
                    foreach (Trait trait in traitpool.ToArray())
                    {
                        bool is_genetic = false;
                        foreach (TraitDef gentrait in genetic_traits)
                        {
                            if (gentrait.defName == trait.def.defName)
                            {
                                is_genetic = true;
                            }
                        }
                        if (!is_genetic)
                        {
                            traitpool.Remove(trait);
                        }
                    }
                }
            }

            // Todo: Perhaps add a way to pass on the parent's body build
            // Best way to do it might be to represent thin/fat/normal/hulk
            // as a pair of two values, strength and weight
            // For example, if the mother has an average body type, she would
            // have a strength of .5f and a weight of .5f. A fat pawn would have
            // a strength of .5f and a weight of .75f. A thin pawn would have a
            // strength of .25f and a weight of .25f. A hulk pawn would have
            // strength of .75f and weight of .75f
            //List<float> strength_pool = new List<float>();
            //List<float> weight_pool = new List<float>();

            //// Get mother and fathers info here if possible

            //float avg_strength = strength_pool.Average();
            //float avg_weight = weight_pool.Average();

            // Surname passing
            string last_name = null;

            if (mother.RaceProps.Humanlike)
            {
                if (father == null)
                {
                    last_name = NameTriple.FromString(mother.Name.ToStringFull).Last;
                }
                else
                {
                    last_name = NameTriple.FromString(father.Name.ToStringFull).Last;
                }
                //Log.Message ("Debug: Newborn is born to the " + last_name + " family.");
            }

            //PawnGenerationRequest request = new PawnGenerationRequest (mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, mother.Map, false, true, false, false, true, false, 1, false, true, true, null, 0, 0, null, skin_whiteness, last_name);
            PawnGenerationRequest request = new PawnGenerationRequest(mother.kindDef, mother.Faction, PawnGenerationContext.NonPlayer, mother.Map.Tile, false, true, false, false, false, false, 1, false, true, true, false, false, null, 0, 0, null, skin_whiteness, last_name);

            Pawn baby = null;

            for (int i = 0; i < num; i++)
            {
                baby = PawnGenerator.GeneratePawn(request);
                if (PawnUtility.TrySpawnHatchedOrBornPawn(baby, mother))
                {
                    if (baby.playerSettings != null && mother.playerSettings != null)
                    {
                        baby.playerSettings.AreaRestriction = mother.playerSettings.AreaRestriction;
                    }
                    if (baby.RaceProps.IsFlesh)
                    {
                        baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, mother);
                        if (father != null)
                        {
                            baby.relations.AddDirectRelation(PawnRelationDefOf.Parent, father);
                        }
                    }

                    // Good until otherwise proven bad
                    bool successful_birth = true;
                    var  disabledBaby     = BackstoryDatabase.allBackstories ["CustomBackstory_NA_Childhood_Disabled"];
                    if (disabledBaby != null)
                    {
                        baby.story.childhood = disabledBaby;
                    }
                    else
                    {
                        Log.Error("Couldn't find the required Backstory: CustomBackstory_NA_Childhood_Disabled!");
                        baby.story.childhood = null;
                    }
                    baby.story.adulthood = null;
                    baby.workSettings.Disable(WorkTypeDefOf.Hunting);                      //hushes up the "has no ranged weapon" alert
                    // remove all traits
                    baby.story.traits.allTraits.Clear();

                    // Add some genetic traits
                    if (traitpool.Count > 0)
                    {
                        for (int j = 0; j != 2; j++)
                        {
                            Trait gentrait = traitpool.RandomElement();
                            if (!baby.story.traits.HasTrait(gentrait.def))
                            {
                                baby.story.traits.GainTrait(gentrait);
                            }
                        }
                    }
                    // Move the baby in front of the mother, rather than on top
                    if (mother.CurrentBed() != null)
                    {
                        baby.Position = baby.Position + new IntVec3(0, 0, 1).RotatedBy(mother.CurrentBed().Rotation);
                    }
                    // else {
                    //	 baby.Position = baby.Position + new IntVec3 (0, 0, 1).RotatedBy (mother.Rotation);
                    // }

                    // The baby died from bad chance of success
                    if (Rand.Value > chance_successful || chance_successful == 0)
                    {
                        successful_birth = false;
                    }

                    // Birth defects via drugs or alcohol
                    if (mother.health.hediffSet.HasHediff(HediffDef.Named("BirthDefectTracker")))
                    {
                        Hediff_BirthDefectTracker tracker = (Hediff_BirthDefectTracker)mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("BirthDefectTracker"));
                        // The baby died in utero from chemical affect
                        if (tracker.stillbirth)
                        {
                            successful_birth = false;
                        }
                        // The baby lived! So far, anyways
                        else
                        {
                            // Should the baby get fetal alcohol syndrome?
                            if (tracker.fetal_alcohol)
                            {
                                baby.health.AddHediff(HediffDef.Named("FetalAlcoholSyndrome"));
                            }
                            // If the mother got high while pregnant, crongrats retard
                            // now your baby is addicted to crack
                            if (tracker.drug_addictions.Count > 0)
                            {
                                foreach (HediffDef addiction in tracker.drug_addictions)
                                {
                                    baby.health.AddHediff(addiction, null, null);
                                }
                            }
                        }
                    }

                    // Inbred?
                    if (father != null && mother.relations.FamilyByBlood.Contains <Pawn> (father))
                    {
                        // 50% chance to get a birth defect from inbreeding
                        if (Rand.Range(0, 1) == 1)
                        {
                            GiveRandomBirthDefect(baby);
                            if (baby.health.hediffSet.HasHediff(HediffDef.Named("DefectStillborn")))
                            {
                                successful_birth = false;
                            }
                        }
                    }



                    // The baby was born! Yay!
                    if (successful_birth == true)
                    {
                        // Give father a happy memory if the birth was successful and he's not dead
                        if (father != null && !father.health.Dead)
                        {
                            // The father is happy the baby was born
                            father.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PartnerGaveBirth"));
                        }

                        // Send a message that the baby was born
                        if (mother.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("HumanPregnancy")).Visible&& PawnUtility.ShouldSendNotificationAbout(mother))
                        {
                            //Messages.Message ("MessageGaveBirth".Translate (new object[] {mother.LabelIndefinite ()}).CapitalizeFirst (), mother, MessageSound.Benefit);
                            Find.LetterStack.ReceiveLetter("LabelGaveBirth".Translate(new object[] { baby.LabelIndefinite() }), "MessageHumanBirth".Translate(new object[] {
                                mother.LabelIndefinite(),
                                baby.Name.ToStringShort
                            }), LetterDefOf.Good, baby, null);
                        }

                        // Try to give PPD. If not, give "New baby" thought
                        float chance = 0.2f;
                        if (mother.story.traits.HasTrait(TraitDefOf.Psychopath))
                        {
                            chance -= 1;
                        }
                        if (mother.story.traits.HasTrait(TraitDef.Named("Nerves")))
                        {
                            chance -= 0.2f * mother.story.traits.GetTrait(TraitDef.Named("Nerves")).Degree;
                        }
                        else if (mother.story.traits.HasTrait(TraitDef.Named("NaturalMood")))
                        {
                            if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == 2)
                            {
                                chance -= 1;
                            }
                            if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == -2)
                            {
                                chance += 0.6f;
                            }
                            // For some reason this is broken

                            /*} else if (mother.story.traits.HasTrait (TraitDef.Named ("Neurotic"))) {
                             * if (mother.story.traits.GetTrait (TraitDef.Named ("Neurotic")).Degree == 1) {
                             *      chance += 0.2f;
                             * } else
                             *      chance += 0.4f;*/
                        }

                        // Because for whatever dumb reason the Math class doesn't have a Clamp method
                        if (chance < 0)
                        {
                            chance = 0;
                        }

                        if (chance > 1)
                        {
                            chance = 1;
                        }
                        Log.Message("Debugging: Chance of PPD is " + chance * 100 + "%");


                        // Try to give PPD
                        if (Rand.Value < chance)
                        {
                            mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("PostPartumDepression"), null);
                            bool verybad = false;
                            if (mother.story.traits.HasTrait(TraitDef.Named("NaturalMood")))
                            {
                                if (mother.story.traits.GetTrait(TraitDef.Named("NaturalMood")).Degree == -2)
                                {
                                    verybad = true;
                                }
                            }
                            else if (mother.story.traits.HasTrait(TraitDef.Named("Neurotic")))
                            {
                                if (mother.story.traits.GetTrait(TraitDef.Named("Neurotic")).Degree == 2)
                                {
                                    verybad = true;
                                }
                            }
                            // This pawn gets an exceptionally bad case of PPD
                            if (verybad)
                            {
                                foreach (Thought_Memory thought in mother.needs.mood.thoughts.memories.Memories)
                                {
                                    if (thought.def.defName == "PostPartumDepression")
                                    {
                                        thought.SetForcedStage(thought.CurStageIndex + 1);
                                    }
                                }
                            }
                        }
                        else
                        {
                            // If we didn't get PPD, then the pawn gets a mood buff
                            if (mother.health.hediffSet.HasHediff(HediffDef.Named("GaveBirthFlag")) == false)
                            {
                                mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirthFirstTime"));
                            }
                            else
                            {
                                mother.needs.mood.thoughts.memories.TryGainMemory(ThoughtDef.Named("IGaveBirth"));
                            }
                        }
                    }
                    else
                    {
                        bool aborted = false;
                        if (chance_successful < 0f)
                        {
                            aborted = true;
                        }
                        if (baby != null)
                        {
                            Miscarry(baby, aborted);
                        }
                    }
                }
                else
                {
                    Find.WorldPawns.PassToWorld(baby, PawnDiscardDecideMode.Discard);
                }
            }
            // Post birth
            if (mother.Spawned)
            {
                // Spawn guck
                FilthMaker.MakeFilth(mother.Position, mother.Map, ThingDefOf.FilthAmnioticFluid, mother.LabelIndefinite(), 5);
                if (mother.caller != null)
                {
                    mother.caller.DoCall();
                }
                if (baby != null)
                {
                    if (baby.caller != null)
                    {
                        baby.caller.DoCall();
                    }
                }

                Log.Message("Birth quality = " + birthing_quality);
                // Possible tearing from pregnancy
                if (birthing_quality < 0.75f)
                {
                    if (birthing_quality < Rand.Value)
                    {
                        // Add a tear from giving birth
                        if (birthing_quality < Rand.Value)
                        {
                            mother.health.AddHediff(HediffDef.Named("PregnancyTearMajor"), ChildrenUtility.GetPawnBodyPart(mother, "Torso"), null);
                        }
                        else
                        {
                            mother.health.AddHediff(HediffDef.Named("PregnancyTear"), ChildrenUtility.GetPawnBodyPart(mother, "Torso"), null);
                        }
                    }
                }
            }
            pawn.health.RemoveHediff(pawn.health.hediffSet.GetFirstHediffOfDef(HediffDef.Named("GivingBirth")));
            pawn.health.RemoveHediff(this);
        }
コード例 #26
0
        public override void Notify_PawnPostApplyDamage(DamageInfo dinfo, float totalDamageDealt)
        {
            int count = Mathf.RoundToInt(totalDamageDealt * props.countPerDamage);

            FilthMaker.TryMakeFilth(Pawn.Position, Pawn.Map, props.filth, Pawn.LabelIndefinite(), count, FilthSourceFlags.Natural);
        }
コード例 #27
0
        public override void GenerateForces(Map map, ResolveParams rp)
        {
            Debug.Log(Debug.ForceGen, "Generating mechanoid forces");

            ScatterOptions options = rp.GetCustom <ScatterOptions>(Constants.ScatterOptions);
            CellRect       rect    = rp.rect;

            /*if (rect.minX < 15 || rect.minZ < 15 || rect.maxX > map.Size.x - 15 || rect.maxZ > map.Size.z - 15) {
             *  return; //do not add enemies if we're on the map edge
             * }
             *
             * if (!CellFinder.TryFindRandomCellInsideWith(rect, (IntVec3 x) => x.Standable(map) && options.roomMap[x.x - rect.BottomLeft.x, x.z - rect.BottomLeft.z] > 1, out IntVec3 testCell)) {
             *  return; //interrupt if there are no closed cells available
             * }*/

            PawnKindDef pawnKindDef = null;

            if (powerMax == 0)
            {
                powerMax = rect.Area / 30.0f;
            }

            powerMax = ScalePointsToDifficulty(powerMax);

            float powerThreshold  = (Math.Abs(Rand.Gaussian(0.5f, 1)) * powerMax) + 1;
            float cumulativePower = 0;

            Faction faction = Faction.OfAncientsHostile;

            Lord lord = LordMaker.MakeNewLord(lordJob: new LordJob_DefendPoint(rect.CenterCell), faction: faction, map: map, startingPawns: null);
            int  tile = map.Tile;

            while (cumulativePower <= powerThreshold)
            {
                PawnKindDef currentPawnKindDef = (from kind in DefDatabase <PawnKindDef> .AllDefsListForReading
                                                  where kind.RaceProps.IsMechanoid
                                                  select kind).RandomElementByWeight((PawnKindDef kind) => 1f / kind.combatPower);

                PawnGenerationRequest request =
                    new PawnGenerationRequest(currentPawnKindDef, faction, PawnGenerationContext.NonPlayer, tile, true, false, false, //allowDead is last
                                              false, true, false, 1f,
                                              false, true, true, false,
                                              false, false, false,
                                              null, null, null, null,
                                              null, null, null, null);

                IntVec3 cell = IntVec3.Invalid;
//                if (!CellFinder.TryFindRandomCellInsideWith(rect, (IntVec3 x) => x.Standable(map) && options.roomMap[x.x - rect.minX, x.z - rect.minZ] > 1, out cell)) {
                CellFinder.TryFindRandomSpawnCellForPawnNear(rect.CenterCell, map, out cell);
//                }

                if (cell != IntVec3.Invalid)
                {
                    Pawn pawn = PawnGenerator.GeneratePawn(request);

                    FilthMaker.MakeFilth(cell, map, ThingDefOf.Filth_Blood, 5);
                    GenSpawn.Spawn(pawn, cell, map, WipeMode.Vanish);

                    lord.AddPawn(pawn);
                    cumulativePower += pawn.kindDef.combatPower;
                }
                else
                {
                    break; //no more suitable cells
                }
            }
        }
コード例 #28
0
        protected override void TimeInterval(float deltaTime)
        {
            base.TimeInterval(deltaTime);
            //float alpha = this.Alpha;
            //Graphic.color.a = alpha;

            //Graphic.MatSingle.color = Graphic.Color;
            //Graphic.MatSingle.SetColor(ShaderPropertyIDs.Color, Graphic.Color);

            if (Destroyed)
            {
                return;
            }

            if (!Flying && !Skidding)
            {
                return;
            }

            var vector = NextExactPosition(deltaTime);
            var intVec = new IntVec3(vector);

            if (intVec != Position)
            {
                if (!intVec.InBounds(Map))
                {
                    Destroy();
                    return;
                }

                if (def.mote.collide && intVec.Filled(Map))
                {
                    WallHit();
                    return;
                }
            }

            Position      = intVec;
            exactPosition = vector;
            if (def.mote.rotateTowardsMoveDirection && velocity != default)
            {
                exactRotation = velocity.AngleFlat();
            }
            else
            {
                exactRotation += rotationRate * deltaTime;
            }

            velocity += def.mote.acceleration * deltaTime;
            if (def.mote.speedPerTime != 0f)
            {
                Speed = Mathf.Max(Speed + (def.mote.speedPerTime * deltaTime), 0f);
            }

            if (airTimeLeft > 0f)
            {
                airTimeLeft -= deltaTime;
                if (airTimeLeft < 0f)
                {
                    airTimeLeft = 0f;
                }

                if (airTimeLeft <= 0f && !def.mote.landSound.NullOrUndefined())
                {
                    def.mote.landSound.PlayOneShot(new TargetInfo(Position, Map));
                }
            }

            if (!Skidding)
            {
                return;
            }

            Speed        *= skidSpeedMultiplierPerTick;
            rotationRate *= skidSpeedMultiplierPerTick;
            if (Speed < 0.02f)
            {
                Speed = 0f;
            }

            var rng = Random.Range(0f, 1f);

            if (rng < 0.3f)
            {
                FilthMaker.TryMakeFilth(intVec, Map, ((MotePropertiesFilthy)def.mote).filthTrace);
            }
        }
コード例 #29
0
        // Token: 0x06002628 RID: 9768 RVA: 0x001222BC File Offset: 0x001206BC
        public override void Tick()
        {
            if (!base.Spawned)
            {
                return;
            }
            this.sustainer.Maintain();
            Vector3    vector      = base.Position.ToVector3Shifted();
            TargetInfo localTarget = new TargetInfo(this);

            Rand.PushState();
            if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors), null, null, out IntVec3 result) && !filthTypes.NullOrEmpty())
            {
                FilthMaker.TryMakeFilth(result, base.Map, filthTypes.RandomElement());
            }
            if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
            {
                Vector3 loc = new Vector3(vector.x, 0f, vector.z);
                loc.y = AltitudeLayer.MoteOverhead.AltitudeFor();
                MoteMaker.ThrowDustPuffThick(loc, base.Map, Rand.Range(1.5f, 3f), Ext?.dustColor ?? new Color(1f, 1f, 1f, 2.5f));

                if (Ext != null && Ext.thowSparksinDust)
                {
                    if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 1f, 0.25f))
                    {
                        MoteMaker.ThrowMicroSparks(loc, base.Map);
                    }
                }
            }
            if (Ext?.effecter != null)
            {
                if (Rand.MTBEventOccurs((EMPMoteSpawnMTB * TimeRemaining), 0.5f, 0.25f))
                {
                    if (this.Effecter == null && Ext.effecter != null)
                    {
                        this.Effecter = new Effecter(Ext.effecter);
                    }
                    if (Effecter != null)
                    {
                        Effecter.EffectTick(localTarget, localTarget);
                    }
                    else
                    {
                        this.Effecter.EffectTick(localTarget, localTarget);
                    }
                }
            }
            if (Rand.MTBEventOccurs(TeleportSpawner.FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, TeleportSpawner.FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out IntVec3 c, 999999))
            {
                FilthMaker.TryMakeFilth(c, base.Map, TeleportSpawner.filthTypes.RandomElement <ThingDef>(), 1);
            }
            if (Rand.MTBEventOccurs(TeleportSpawner.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 (secondarySpawnTick > Find.TickManager.TicksGame)
            {
                return;
            }
            if (this.Effecter != null)
            {
                this.Effecter.Cleanup();
            }
            this.sustainer.End();
            Map     map      = base.Map;
            IntVec3 position = base.Position;

            if (Ext != null)
            {
                if (Ext.strikespreexplode)
                {
                    FireEvent(map, position);
                }
                if (Ext.explodesprespawn)
                {
                    GenExplosion.DoExplosion(position, map, Ext.blastradius, Ext.damageDef, null, -1, -1f, null, null, null, null, null, 0f, 1, false, null, 0f, 1, 0f, false);
                }
            }
            if (!this.innerContainer.NullOrEmpty())
            {
                //    Log.Message(string.Format("{0} to drop", innerContainer.ContentsString));
                this.innerContainer.TryDropAll(position, map, ThingPlaceMode.Near);
            }
            this.Destroy(DestroyMode.Vanish);
        }
コード例 #30
0
        // Token: 0x060000EF RID: 239 RVA: 0x00008640 File Offset: 0x00006840
        public static bool CompleteConstruction_Prefix(Frame __instance, Pawn worker)
        {
            bool flag = !worker.RaceProps.Humanlike;
            bool result;

            if (flag)
            {
                Thing thing = __instance.holdingOwner.Take(__instance);
                __instance.resourceContainer.ClearAndDestroyContents(DestroyMode.Vanish);
                Map map = worker.Map;
                __instance.Destroy(DestroyMode.Vanish);
                bool flag2 = __instance.GetStatValue(StatDefOf.WorkToBuild, true) > 150f && __instance.def.entityDefToBuild is ThingDef && ((ThingDef)__instance.def.entityDefToBuild).category == ThingCategory.Building;
                if (flag2)
                {
                    SoundDefOf.Building_Complete.PlayOneShot(new TargetInfo(thing.Position, map, false));
                }
                ThingDef thingDef = __instance.def.entityDefToBuild as ThingDef;
                Thing    thing2   = null;
                bool     flag3    = thingDef != null;
                if (flag3)
                {
                    thing2 = ThingMaker.MakeThing(thingDef, thing.Stuff);
                    thing2.SetFactionDirect(thing.Faction);
                    CompQuality compQuality = thing2.TryGetComp <CompQuality>();
                    bool        flag4       = compQuality != null;
                    if (flag4)
                    {
                        int             relevantSkillLevel = 1;
                        QualityCategory q = QualityUtility.GenerateQualityCreatedByPawn(relevantSkillLevel, false);
                        compQuality.SetQuality(q, ArtGenerationContext.Colony);
                        QualityUtility.SendCraftNotification(thing2, worker);
                    }
                    CompArt compArt = thing2.TryGetComp <CompArt>();
                    bool    flag5   = compArt != null;
                    if (flag5)
                    {
                        bool flag6 = compQuality == null;
                        if (flag6)
                        {
                            compArt.InitializeArt(ArtGenerationContext.Colony);
                        }
                        compArt.JustCreatedBy(worker);
                    }
                    thing2.HitPoints = Mathf.CeilToInt((float)__instance.HitPoints / (float)thing.MaxHitPoints * (float)thing2.MaxHitPoints);
                    GenSpawn.Spawn(thing2, thing.Position, worker.Map, thing.Rotation, WipeMode.Vanish, false);
                }
                else
                {
                    map.terrainGrid.SetTerrain(thing.Position, (TerrainDef)__instance.def.entityDefToBuild);
                    FilthMaker.RemoveAllFilth(thing.Position, map);
                }
                worker.records.Increment(RecordDefOf.ThingsConstructed);
                bool flag7 = thing2 != null && thing2.GetStatValue(StatDefOf.WorkToBuild, true) >= 9500f;
                if (flag7)
                {
                    TaleRecorder.RecordTale(TaleDefOf.CompletedLongConstructionProject, new object[]
                    {
                        worker,
                        thing2.def
                    });
                }
                result = false;
            }
            else
            {
                result = true;
            }
            return(result);
        }