Example #1
0
        private void StartRotationSound()
        {
            StopRotationSound();
            SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.None);

            this.rotationSoundSustainer = this.def.building.soundDispense.TrySpawnSustainer(info);
        }
Example #2
0
    private void StartWickSustainer()
    {
        SoundStarter.PlayOneShot(CompExplosiveNuke.PreImpact, (SoundInfo)this.parent.Position);
        SoundInfo info = SoundInfo.InWorld((TargetInfo)((Thing)this.parent), MaintenanceType.PerTick);

        this.wickSoundSustainer = SoundStarter.TrySpawnSustainer(CompExplosiveNuke.Null, info);
    }
Example #3
0
        public override void EjectContents()
        {
            ThingDef named = DefDatabase <ThingDef> .GetNamed("FilthSlime", true);

            foreach (Thing current in this.container)
            {
                Pawn pawn = current as Pawn;
                if (pawn != null)
                {
                    pawn.filth.GainFilth(named);

                    if (this.IcookingTicking != IcookingTime)
                    {
                        PawnChanger.ExecuteBadThings(pawn);
                    }
                }
            }
            if (!base.Destroyed)
            {
                SoundDef.Named("CryptosleepCasketEject").PlayOneShot(SoundInfo.InWorld(base.Position, MaintenanceType.None));
            }
            this.IcookingTicking = 0;
            ChangeColour(this.red);
            base.EjectContents();
        }
Example #4
0
        //Added new calculations for downed pawns, destination
        public virtual void Launch(Thing launcher, Vector3 origin, TargetInfo targ, Thing equipment = null)
        {
            if (this.shotSpeed < 0)
            {
                this.shotSpeed = this.def.projectile.speed;
            }
            this.launcher = launcher;
            this.origin   = origin;
            if (equipment != null)
            {
                this.equipmentDef = equipment.def;
            }
            else
            {
                this.equipmentDef = null;
            }
            //Checking if target was downed on launch
            if (targ.Thing != null)
            {
                this.assignedTarget = targ.Thing;
            }
            //Checking if a new destination was set
            if (this.destination == null)
            {
                this.destination = targ.Cell.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f));
            }

            this.ticksToImpact = this.StartingTicksToImpact;
            if (!this.def.projectile.soundAmbient.NullOrUndefined())
            {
                SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.PerTick);
                this.ambientSustainer = this.def.projectile.soundAmbient.TrySpawnSustainer(info);
            }
        }
 public override void PostApplyDamage(DamageInfo dinfo)
 {
     if (!base.Destroyed && this.ticksToExplode == 0 && dinfo.Def == DamageTypeDefOf.Flame && Rand.Value < 0.05f && base.GetComp <CompPowerBattery>().StoredEnergy > 500f)
     {
         this.ticksToExplode = Rand.Range(70, 150);
         SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.PerTick);
         this.wickSustainer = Building_BatteryMk2.WickSound.TrySpawnSustainer(info);
     }
 }
 public void FinishReload()
 {
     SoundStarter.PlayOneShot(this.parent.def.soundInteract, SoundInfo.InWorld(this.Wielder.Position, 0));
     if (this.reloaderProp.throwMote)
     {
         MoteThrower.ThrowText(this.Wielder.Position.ToVector3Shifted(), Translator.Translate("CR_ReloadedMote"), -1);
     }
     this.count      = this.reloaderProp.roundPerMag;
     this.needReload = false;
 }
Example #7
0
 public void FinishReload()
 {
     parent.def.soundInteract.PlayOneShot(SoundInfo.InWorld(Wielder.Position));
     if (reloaderProp.throwMote)
     {
         MoteThrower.ThrowText(Wielder.Position.ToVector3Shifted(), "CR_ReloadedMote".Translate());
     }
     count      = reloaderProp.roundPerMag;
     needReload = false;
 }
Example #8
0
    public override void SpawnSetup()
    {
        base.SpawnSetup();
        RecalcPathsOnAndAroundMe();
        Find.ConceptTracker.TeachOpportunity(ConceptDefOf.HomeRegion, this, OpportunityType.Important);


        SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.PerTick);

        sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, BurningSoundDef, info);
    }
Example #9
0
        public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
        {
            base.Destroy(mode);

            this.launcher.NotifyTargetIsDestroyedOrMissed(this.target);
            if (mode == DestroyMode.Kill)
            {
                MoteMaker.ThrowLightningGlow(this.DrawPos, 6f);
                for (int smokeIndex = 0; smokeIndex < 3; smokeIndex++)
                {
                    MoteMaker.ThrowSmoke(this.DrawPos + new Vector3(Rand.Range(0, 1), 0, Rand.Range(0, 1)), 3f);
                }
                SoundInfo infos = SoundInfo.InWorld(this);
                SoundDef.Named("Explosion_Bomb").PlayOneShot(infos);
            }
        }
Example #10
0
        private void LaunchMissile(DropPodIncoming dropPod)
        {
            const int ticksToImpactOffsetAverage = 40;

            bool    targetWillBeHit            = true;
            float   landingDistanceCoefficient = 0f;
            Vector3 missPositionOffset;

            // Determine if drop pod will be hit.
            if (Rand.Value < 0.8f)
            {
                targetWillBeHit    = true;
                missPositionOffset = new Vector3(0, 0, 0);
            }
            else
            {
                targetWillBeHit    = false;
                missPositionOffset = new Vector3(5, 0, 5).RotatedBy(Rand.Range(0, 360));
            }

            // Compute predicted target impact position and time.
            int dropPodTicksToLanding  = (int)(typeof(DropPodIncoming).GetField("ticksToImpact", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).GetValue(dropPod));
            int ticksToImpactOffset    = ticksToImpactOffsetAverage + Rand.RangeInclusive(-10, 10);
            int predictedTicksToImpact = dropPodTicksToLanding - ticksToImpactOffset;

            landingDistanceCoefficient = (float)(ticksToImpactOffset * ticksToImpactOffset) * 0.01f;
            Vector3        predictedImpactPosition = dropPod.Position.ToVector3ShiftedWithAltitude(AltitudeLayer.FlyingItem) + new Vector3(-landingDistanceCoefficient * 0.4f, 0, +landingDistanceCoefficient * 0.6f) + missPositionOffset;
            Projectile_Sam sam = ThingMaker.MakeThing(ThingDef.Named("Sam")) as Projectile_Sam;

            sam.InitializeMissileData(this, dropPod, this.Position.ToVector3Shifted(), predictedImpactPosition, predictedTicksToImpact, targetWillBeHit);
            GenSpawn.Spawn(sam, this.Position);
            this.missilesLoadedNumber--;

            // Update turret rotation.
            this.patrolTicksToNextRotation = patrolRotationIntervalMin;
            this.turretRotation            = (predictedImpactPosition - this.DrawPos).AngleFlat();
            StopRotationSound();

            // Throw smoke and play missile launch sound.
            MoteMaker.ThrowSmoke(this.DrawPos, 2f);
            SoundInfo infos = SoundInfo.InWorld(this);

            OG_Util.MissileLaunchSoundDef.PlayOneShot(infos);
        }
        public override void SpawnSetup()
        {
            base.SpawnSetup();

            ToolsForHaulUtility.CartTurret.Add(this);

            if (mountableComp.Driver != null && IsCurrentlyMotorized())
            {
                LongEventHandler.ExecuteWhenFinished(delegate
                {
                    SoundInfo info = SoundInfo.InWorld(this);
                    mountableComp.sustainerAmbient = vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                });
            }

            if (mountableComp.Driver != null)
            {
                mountableComp.Driver.RaceProps.makesFootprints = false;

                if (mountableComp.Driver.RaceProps.Humanlike)
                {
                    mountableComp.driverComp = new CompDriver {
                        vehicle = this
                    };
                    mountableComp.Driver.AllComps?.Add(mountableComp.driverComp);
                    mountableComp.driverComp.parent = mountableComp.Driver;
                }
            }

            //if (allowances == null)
            //{
            //    allowances = new ThingFilter();
            //    allowances.SetFromPreset(StorageSettingsPreset.DefaultStockpile);
            //    allowances.SetFromPreset(StorageSettingsPreset.DumpingStockpile);
            //}

            LongEventHandler.ExecuteWhenFinished(UpdateGraphics);
        }
Example #12
0
        public void TreatRocketProjectile(ProjectileWithAngle projectileWithAngle)
        {
            float rocketAbsorbtionCost = ForceFieldGeneratorProperties.forceFieldMaxCharge * ForceFieldGeneratorProperties.rocketAbsorbtionProportion;

            if (this.forceFieldCharge > rocketAbsorbtionCost)
            {
                this.forceFieldCharge -= rocketAbsorbtionCost;
                if (this.forceFieldCharge <= 0)
                {
                    this.forceFieldCharge = 0;
                    this.forceFieldState  = ForceFieldState.Offline;
                }
                SoundInfo soundInfo = SoundInfo.InWorld(projectileWithAngle.projectile.Position, MaintenanceType.None);
                SoundDefOf.Thunder_OnMap.PlayOneShot(soundInfo);
                GenExplosion.DoExplosion(projectileWithAngle.projectile.Position, 1.9f, DamageDefOf.Flame, null, null, null);
                projectileWithAngle.projectile.Destroy();
                ActivateMatrixAbsorbtionEffect(projectileWithAngle.projectile.ExactPosition);
            }
            else
            {
                this.forceFieldCharge = 0;
                this.forceFieldState  = ForceFieldState.Offline;
            }
        }
        public void MountOn(Pawn pawn)
        {
            if (Driver != null)
            {
                return;
            }

            Building_Reloadable turret = (parent as Building_Reloadable);

            if (turret != null)
            {
                turret.dontReload = true;
            }

            // Check to make pawns not mount two vehicles at once
            if (ToolsForHaulUtility.IsDriver(pawn))
            {
                if (ToolsForHaulUtility.GetCartByDriver(pawn) != null)
                {
                    ToolsForHaulUtility.GetCartByDriver(pawn).mountableComp.Dismount();
                }

                if (ToolsForHaulUtility.GetTurretByDriver(pawn) != null)
                {
                    ToolsForHaulUtility.GetTurretByDriver(pawn).mountableComp.Dismount();
                }
            }

            Driver = pawn;

            MapComponent_ToolsForHaul.currentVehicle.Add(pawn, parent);

            if (Driver.RaceProps.Humanlike)
            {
                Driver.RaceProps.makesFootprints = false;
            }

            if (pawn.RaceProps.Humanlike)
            {
                driverComp = new CompDriver {
                    vehicle = parent as Building
                };
                Driver?.AllComps?.Add(driverComp);
                driverComp.parent = Driver;
            }

            Vehicle_Cart vehicleCart = parent as Vehicle_Cart;

            if (vehicleCart != null)
            {
                // Set faction of vehicle to whoever mounts it
                if (vehicleCart.Faction != Driver.Faction && vehicleCart.ClaimableBy(Driver.Faction))
                {
                    parent.SetFaction(Driver.Faction);
                }


                if (vehicleCart.IsCurrentlyMotorized())
                {
                    SoundInfo info = SoundInfo.InWorld(parent);
                    sustainerAmbient = vehicleCart.vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                }


                return;
            }

            Vehicle_Turret vehicleTurret = parent as Vehicle_Turret;

            if (vehicleTurret != null)
            {
                // Set faction of vehicle to whoever mounts it
                if (vehicleTurret.Faction != Driver.Faction && vehicleTurret.ClaimableBy(Driver.Faction))
                {
                    parent.SetFaction(Driver.Faction);
                }

                if (vehicleTurret.IsCurrentlyMotorized())
                {
                    SoundInfo info = SoundInfo.InWorld(parent);
                    sustainerAmbient = vehicleTurret.vehicleComp.compProps.soundAmbient.TrySpawnSustainer(info);
                }

                return;
            }
        }
        public override bool TryExecute(IncidentParms parms)
        {
            IntVec3 spawnSpot;

            if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.CanReachColony(), out spawnSpot))
            {
                return(false);
            }
            Faction faction = Find.FactionManager.FirstFactionOfDef(FactionDefOf.Spacer);
            PawnGenerationRequest request = new PawnGenerationRequest(PawnKindDefOf.SpaceRefugee, faction, PawnGenerationContext.NonPlayer, false, false, false, false, true, false, RelationWithColonistWeight, false, true, true, null, null, null, null, null);
            Pawn refugee = PawnGenerator.GeneratePawn(request);

            refugee.relations.everSeenByPlayer = true;
            Faction enemyFac;

            if (!(from f in Find.FactionManager.AllFactions
                  where !f.def.hidden && f.HostileTo(Faction.OfPlayer)
                  select f).TryRandomElement(out enemyFac))
            {
                return(false);
            }
            string text = "RefugeeChasedInitial".Translate(new object[]
            {
                refugee.Name.ToStringFull,
                refugee.story.adulthood.title.ToLower(),
                enemyFac.def.pawnsPlural,
                enemyFac.Name,
                refugee.ageTracker.AgeBiologicalYears
            });

            text = text.AdjustedFor(refugee);
            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, refugee);
            DiaNode   diaNode   = new DiaNode(text);
            DiaOption diaOption = new DiaOption("RefugeeChasedInitial_Accept".Translate());

            diaOption.action = delegate
            {
                GenSpawn.Spawn(refugee, spawnSpot);
                refugee.SetFaction(Faction.OfPlayer);

                // Refugee stole vehicle?
                float value = Rand.Value;
                if (enemyFac.def.techLevel >= TechLevel.Industrial && value >= 0.33f)
                {
                    CellFinder.RandomClosewalkCellNear(spawnSpot, 5);
                    Thing thing;
                    if (value >= 0.8f)
                    {
                        thing = ThingMaker.MakeThing(ThingDef.Named("VehicleCombatATV"));
                    }
                    else
                    {
                        thing = ThingMaker.MakeThing(ThingDef.Named("VehicleATV"));
                    }
                    GenSpawn.Spawn(thing, spawnSpot);

                    Thing fuel = ThingMaker.MakeThing(thing.TryGetComp <CompRefuelable>().Props.fuelFilter.AllowedThingDefs.FirstOrDefault());
                    fuel.stackCount += Mathf.FloorToInt(5 + Rand.Value * 15f);
                    thing.TryGetComp <CompRefuelable>().Refuel(fuel);
                    int num2 = Mathf.FloorToInt(Rand.Value * 0.3f * thing.MaxHitPoints);
                    thing.TakeDamage(new DamageInfo(DamageDefOf.Bullet, num2, null, null));
                    thing.SetFaction(Faction.OfPlayer);

                    Job job = new Job(HaulJobDefOf.Mount);
                    Find.Reservations.ReleaseAllForTarget(thing);
                    job.targetA = thing;
                    refugee.jobs.StartJob(job, JobCondition.InterruptForced);

                    SoundInfo info = SoundInfo.InWorld(thing);
                    thing.TryGetComp <CompMountable>().sustainerAmbient = thing.TryGetComp <CompVehicle>().compProps.soundAmbient.TrySpawnSustainer(info);
                }


                Find.CameraDriver.JumpTo(spawnSpot);
                IncidentParms incidentParms = StorytellerUtility.DefaultParmsNow(Find.Storyteller.def, IncidentCategory.ThreatBig);
                incidentParms.forced          = true;
                incidentParms.faction         = enemyFac;
                incidentParms.raidStrategy    = RaidStrategyDefOf.ImmediateAttack;
                incidentParms.raidArrivalMode = PawnsArriveMode.EdgeWalkIn;
                incidentParms.spawnCenter     = spawnSpot;
                incidentParms.points         *= RaidPointsFactor;
                QueuedIncident qi = new QueuedIncident(new FiringIncident(IncidentDefOf.RaidEnemy, null, incidentParms), Find.TickManager.TicksGame + RaidDelay.RandomInRange);
                Find.Storyteller.incidentQueue.Add(qi);
            };
            diaOption.resolveTree = true;
            diaNode.options.Add(diaOption);
            string text2 = "RefugeeChasedRejected".Translate(new object[]
            {
                refugee.NameStringShort
            });
            DiaNode   diaNode2   = new DiaNode(text2);
            DiaOption diaOption2 = new DiaOption("OK".Translate());

            diaOption2.resolveTree = true;
            diaNode2.options.Add(diaOption2);
            DiaOption diaOption3 = new DiaOption("RefugeeChasedInitial_Reject".Translate());

            diaOption3.action = delegate
            {
                Find.WorldPawns.PassToWorld(refugee);
            };
            diaOption3.link = diaNode2;
            diaNode.options.Add(diaOption3);
            Find.WindowStack.Add(new Dialog_NodeTree(diaNode, true, true));
            return(true);
        }
Example #15
0
        public override bool TryExecute(IncidentParms parms)
        {
            IntVec3 loc;

            if (!CellFinder.TryFindRandomEdgeCellWith((IntVec3 c) => c.CanReachColony(), out loc))
            {
                return(false);
            }
            PawnKindDef pawnKindDef = new List <PawnKindDef>
            {
                PawnKindDefOf.Villager
            }.RandomElement <PawnKindDef>();
            PawnGenerationRequest request = new PawnGenerationRequest(pawnKindDef, Faction.OfPlayer, PawnGenerationContext.NonPlayer, false, false, false, false, true, false, RelationWithColonistWeight, false, true, true, null, null, null, null, null, null);
            Pawn pawn = PawnGenerator.GeneratePawn(request);

            GenSpawn.Spawn(pawn, loc);

            // vehicle generation
            // Vehicles for raiders
            // lowered probability for shield users as they are overpowered


            if (pawn.RaceProps.ToolUser)
            {
                float value = Rand.Value;
                if (value >= 0.5f)
                {
                    CellFinder.RandomClosewalkCellNear(pawn.Position, 5);
                    Thing thing;

                    if (value >= 0.95f)
                    {
                        thing = ThingMaker.MakeThing(ThingDef.Named("VehicleCombatATV"));
                    }
                    else
                    {
                        thing = ThingMaker.MakeThing(ThingDef.Named("VehicleATV"));
                    }

                    GenSpawn.Spawn(thing, pawn.Position);

                    Thing fuel = ThingMaker.MakeThing(thing.TryGetComp <CompRefuelable>().Props.fuelFilter.AllowedThingDefs.FirstOrDefault());
                    fuel.stackCount += Mathf.FloorToInt(5 + Rand.Value * 15f);
                    thing.TryGetComp <CompRefuelable>().Refuel(fuel);
                    int num2 = Mathf.FloorToInt(Rand.Value * 0.2f * thing.MaxHitPoints);
                    thing.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, num2, null, null));
                    thing.SetFaction(Faction.OfPlayer);

                    Job job = new Job(HaulJobDefOf.Mount);
                    Find.Reservations.ReleaseAllForTarget(thing);
                    job.targetA = thing;
                    pawn.jobs.StartJob(job, JobCondition.InterruptForced, null, true);

                    SoundInfo info = SoundInfo.InWorld(thing);
                    thing.TryGetComp <CompMountable>().sustainerAmbient = thing.TryGetComp <CompVehicle>().compProps.soundAmbient.TrySpawnSustainer(info);
                }
            }


            string text = "WandererJoin".Translate(new object[]
            {
                pawnKindDef.label,
                pawn.story.adulthood.title.ToLower()
            });

            text = text.AdjustedFor(pawn);
            string label = "LetterLabelWandererJoin".Translate();

            PawnRelationUtility.TryAppendRelationsWithColonistsInfo(ref text, ref label, pawn);
            Find.LetterStack.ReceiveLetter(label, text, LetterType.Good, pawn, null);
            return(true);
        }
Example #16
0
        public void LoadAmmo(Thing ammo = null)
        {
            if (wielder == null && turret == null)
            {
                Log.Error(parent.ToString() + " tried loading ammo with no owner");
                return;
            }

            int newMagCount;

            if (useAmmo)
            {
                Thing ammoThing;
                bool  ammoFromInventory = false;
                if (ammo == null)
                {
                    if (!TryFindAmmoInInventory(out ammoThing))
                    {
                        this.DoOutOfAmmoAction();
                        return;
                    }
                    ammoFromInventory = true;
                }
                else
                {
                    ammoThing = ammo;
                }
                currentAmmoInt = (AmmoDef)ammoThing.def;
                if (Props.magazineSize < ammoThing.stackCount)
                {
                    newMagCount           = Props.magazineSize;
                    ammoThing.stackCount -= Props.magazineSize;
                    if (compInventory != null)
                    {
                        compInventory.UpdateInventory();
                    }
                }
                else
                {
                    newMagCount = ammoThing.stackCount;
                    if (ammoFromInventory)
                    {
                        compInventory.container.Remove(ammoThing);
                    }
                    else if (!ammoThing.Destroyed)
                    {
                        ammoThing.Destroy();
                    }
                }
            }
            else
            {
                newMagCount = Props.magazineSize;
            }
            curMagCountInt = newMagCount;
            if (turret != null)
            {
                turret.isReloading = false;
            }
            if (parent.def.soundInteract != null)
            {
                parent.def.soundInteract.PlayOneShot(SoundInfo.InWorld(position));
            }
            if (Props.throwMote)
            {
                MoteThrower.ThrowText(position.ToVector3Shifted(), "CR_ReloadedMote".Translate());
            }
        }
        public override bool TryExecute(IncidentParms parms)
        {
            //    if (!base.TryExecute(parms))
            {
                ResolveRaidPoints(parms);
                if (!TryResolveRaidFaction(parms))
                {
                    return(false);
                }
                ResolveRaidStrategy(parms);
                ResolveRaidArriveMode(parms);
                ResolveRaidSpawnCenter(parms);
                PawnGroupMakerUtility.AdjustPointsForGroupArrivalParams(parms);
                List <Pawn> list = PawnGroupMakerUtility.GenerateArrivingPawns(parms).ToList();
                if (list.Count == 0)
                {
                    Log.Error("Got no pawns spawning raid from parms " + parms);
                    return(false);
                }
                TargetInfo letterLookTarget = TargetInfo.Invalid;
                if (parms.raidArrivalMode == PawnsArriveMode.CenterDrop || parms.raidArrivalMode == PawnsArriveMode.EdgeDrop)
                {
                    DropPodUtility.DropThingsNear(parms.spawnCenter, list.Cast <Thing>(), parms.raidPodOpenDelay, true, true);
                    letterLookTarget = parms.spawnCenter;
                }
                else
                {
                    foreach (Pawn current in list)
                    {
                        float   value  = Rand.Value;
                        IntVec3 intVec = CellFinder.RandomClosewalkCellNear(parms.spawnCenter, 8);
                        GenSpawn.Spawn(current, intVec);

                        letterLookTarget = current;

                        // Vehicles for raiders
                        // lowered probability for shield users as they are overpowered

                        bool isShieldUser = false;

                        if (parms.faction.def.techLevel >= TechLevel.Industrial && current.RaceProps.fleshType != FleshType.Mechanoid && current.RaceProps.ToolUser)
                        {
                            List <Apparel> wornApparel = current.apparel.WornApparel;
                            for (int i = 0; i < wornApparel.Count; i++)
                            {
                                if (wornApparel[i] is PersonalShield)
                                {
                                    isShieldUser = true;
                                    break;
                                }
                            }
                            if (value >= 0.66f && !isShieldUser || isShieldUser && value > 0.9f)
                            {
                                CellFinder.RandomClosewalkCellNear(current.Position, 5);
                                Thing thing = ThingMaker.MakeThing(ThingDef.Named("VehicleATV"));

                                if (value >= 0.9f && !isShieldUser)
                                {
                                    thing = ThingMaker.MakeThing(ThingDef.Named("VehicleCombatATV"));
                                }

                                GenSpawn.Spawn(thing, current.Position);

                                Job job = new Job(HaulJobDefOf.Mount);
                                Find.Reservations.ReleaseAllForTarget(thing);
                                job.targetA = thing;
                                current.jobs.StartJob(job, JobCondition.InterruptForced, null, true);

                                int num2 = Mathf.FloorToInt(Rand.Value * 0.2f * thing.MaxHitPoints);
                                thing.TakeDamage(new DamageInfo(DamageDefOf.Deterioration, num2, null, null));

                                SoundInfo info = SoundInfo.InWorld(thing);
                                thing.TryGetComp <CompMountable>().sustainerAmbient = thing.TryGetComp <CompVehicle>().compProps.soundAmbient.TrySpawnSustainer(info);
                            }
                        }
                    }
                }
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine("Points = " + parms.points.ToString("F0"));

                foreach (Pawn current2 in list)
                {
                    string str = (current2.equipment == null || current2.equipment.Primary == null) ? "unarmed" : current2.equipment.Primary.LabelCap;
                    stringBuilder.AppendLine(current2.KindLabel + " - " + str);
                }
                Find.LetterStack.ReceiveLetter(GetLetterLabel(parms), GetLetterText(parms, list), GetLetterType(), letterLookTarget, stringBuilder.ToString());
                if (GetLetterType() == LetterType.BadUrgent)
                {
                    TaleRecorder.RecordTale(TaleDefOf.RaidArrived);
                }
                PawnRelationUtility.Notify_PawnsSeenByPlayer(list, GetRelatedPawnsInfoLetterText(parms), true);
                Lord lord = LordMaker.MakeNewLord(parms.faction, parms.raidStrategy.Worker.MakeLordJob(ref parms), list);
                AvoidGridMaker.RegenerateAvoidGridsFor(parms.faction);
                LessonAutoActivator.TeachOpportunity(ConceptDefOf.EquippingWeapons, OpportunityType.Critical);
                if (!PlayerKnowledgeDatabase.IsComplete(ConceptDefOf.PersonalShields))
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        Pawn pawn = list[i];
                        if (pawn.apparel.WornApparel.Any(ap => ap is PersonalShield))
                        {
                            LessonAutoActivator.TeachOpportunity(ConceptDefOf.PersonalShields, OpportunityType.Critical);
                            break;
                        }
                    }
                }
                if (DebugViewSettings.drawStealDebug && parms.faction.HostileTo(Faction.OfPlayer))
                {
                    Log.Message(string.Concat("Market value threshold to start stealing: ", StealAIUtility.StartStealingMarketValueThreshold(lord), " (colony wealth = ", Find.StoryWatcher.watcherWealth.WealthTotal, ")"));
                }
            }
            Find.TickManager.slower.SignalForceNormalSpeedShort();
            Find.StoryWatcher.statsRecord.numRaidsEnemy++;

            return(true);
        }