Example #1
0
 public void PlaySound(SapientCalls.Call sound)
 {
     if (sound != null && Find.CameraDriver.CurrentViewRect.ExpandedBy(10).Contains(Pawn.Position))
     {
         SoundInfo info = SoundInfo.InMap(new TargetInfo(Pawn.PositionHeld, Pawn.MapHeld));
         Rand.PushState();
         sound.sound.PlayOneShot(info);
         Rand.PopState();
     }
 }
Example #2
0
        private void StartSustainerPoweredIfInactive()
        {
            CompProperties_Power props = base.Props;

            if (!props.soundAmbientPowered.NullOrUndefined() && this.sustainerPowered == null)
            {
                SoundInfo info = SoundInfo.InMap(this.parent, MaintenanceType.None);
                this.sustainerPowered = props.soundAmbientPowered.TrySpawnSustainer(info);
            }
        }
Example #3
0
 private void CheckSpawnSustainer()
 {
     if (this.TicksLeft >= 0)
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             this.sustainer = SoundDef.Named("OrbitalBeam").TrySpawnSustainer(SoundInfo.InMap(this.selectedTarget, MaintenanceType.PerTick));
         });
     }
 }
Example #4
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            base.SpawnSetup(map, respawningAfterLoad);

            if (!def.projectile.soundAmbient.NullOrUndefined())
            {
                SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
                ambientSustainer = def.projectile.soundAmbient.TrySpawnSustainer(info);
            }
        }
 private void CheckSpawnSustainer()
 {
     if (this.TicksLeft >= this.fadeOutDuration && this.Props.sound != null)
     {
         LongEventHandler.ExecuteWhenFinished(delegate
         {
             this.sustainer = this.Props.sound.TrySpawnSustainer(SoundInfo.InMap(base.parent, MaintenanceType.PerTick));
         });
     }
 }
        public override void Impact_Override(Thing hitThing)
        {
            Map map = base.Map;

            base.Impact_Override(hitThing);
            Pawn pawn = this.launcher as Pawn;

            if (pawn != null)
            {
                CompAbilityUserMagic comp = pawn.GetComp <CompAbilityUserMagic>();
                if (comp.IsMagicUser)
                {
                    this.arcaneDmg = comp.arcaneDmg;
                }
            }

            bool flag = hitThing != null;

            if (flag)
            {
                int        DamageAmount = Mathf.RoundToInt(this.def.projectile.GetDamageAmount(1, null) * this.arcaneDmg);
                DamageInfo dinfo        = new DamageInfo(this.def.projectile.damageDef, DamageAmount, 0, this.ExactRotation.eulerAngles.y, this.launcher, null, this.equipmentDef, DamageInfo.SourceCategory.ThingOrUnknown);
                hitThing.TakeDamage(dinfo);

                bool flag2 = this.canStartFire && Rand.Range(0f, 1f) > this.startFireChance;
                if (flag2)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                Pawn hitTarget;
                bool flag3 = (hitTarget = (hitThing as Pawn)) != null;
                if (flag3)
                {
                    this.PostImpactEffects(this.launcher as Pawn, hitTarget);
                    FleckMaker.ThrowMicroSparks(this.destination, base.Map);
                }
            }
            else
            {
                FleckMaker.ThrowMicroSparks(this.ExactPosition, base.Map);
            }
            for (int i = 0; i <= 1; i++)
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None);
                //SoundDef.Named("TM_Thunder_OnMap");
            }
            CellRect cellRect = CellRect.CenteredOn(hitThing.Position, 2);

            cellRect.ClipInsideMap(map);
            for (int i = 0; i < Rand.Range(1, 3); i++)
            {
                IntVec3 randomCell = cellRect.RandomCell;
                this.StaticExplosion(randomCell, map, 0.4f);
            }
        }
        private void StartSustainerHot()
        {
            if (sustainerHot != null || Settings.disableServersAlarm)
            {
                return;
            }

            var info = SoundInfo.InMap(parent);

            sustainerHot = Props.hotSoundDef.TrySpawnSustainer(info);
        }
 public static void PlayNearestLifestageSound(Pawn pawn, Func <LifeStageAge, SoundDef> getter, float volumeFactor = 1f)
 {
     GetNearestLifestageSound(pawn, getter, out var def, out var pitch, out var volume);
     if (def != null && pawn.SpawnedOrAnyParentSpawned)
     {
         SoundInfo info = SoundInfo.InMap(new TargetInfo(pawn.PositionHeld, pawn.MapHeld));
         info.pitchFactor  = pitch;
         info.volumeFactor = volume * volumeFactor;
         def.PlayOneShot(info);
     }
 }
Example #9
0
        private void StartSustainer()
        {
            if (sustainer != null || Props.ambiance == "None" || Settings.disableServersAmbiance)
            {
                return;
            }

            var info = SoundInfo.InMap(parent);

            sustainer = ambiance.TrySpawnSustainer(info);
        }
Example #10
0
        private void StartSustainer()
        {
            if (this.sustainer == null && this.Props.ambiance != "None" && !Settings.disableServersAmbiance)
            {
                SoundInfo info = SoundInfo.InMap(this.parent, MaintenanceType.None);
                this.sustainer = this.ambiance.TrySpawnSustainer(info);
                //this.sustainer = SoundDefOf.GeyserSpray.TrySpawnSustainer(info);

                //this.sustainerHot = SoundDefOf.GeyserSpray.TrySpawnSustainer(info);
            }
        }
        public override void ExtraCrafterTickAction()
        {
            if (!this.powerComp.PowerOn && this.soundSustainer != null && !this.soundSustainer.Ended)
            {
                this.soundSustainer.End();
            }
            switch (this.crafterStatus)
            {
            case CrafterStatus.Filling:
                if (!this.powerComp.PowerOn || Current.Game.tickManager.TicksGame % 300 != 0)
                {
                    break;
                }
                MoteMaker.ThrowSmoke(this.Position.ToVector3(), this.Map, 1f);
                break;

            case CrafterStatus.Crafting:
                if (this.powerComp.PowerOn && Current.Game.tickManager.TicksGame % 100 == 0)
                {
                    for (int index = 0; index < 5; ++index)
                    {
                        MoteMaker.ThrowMicroSparks(this.Position.ToVector3() + new Vector3((float)Rand.Range(-1, 1), 0.0f, (float)Rand.Range(-1, 1)), this.Map);
                    }
                    for (int index = 0; index < 3; ++index)
                    {
                        MoteMaker.ThrowSmoke(this.Position.ToVector3() + new Vector3(Rand.Range(-1f, 1f), 0.0f, Rand.Range(-1f, 1f)), this.Map, Rand.Range(0.5f, 0.75f));
                    }
                    MoteMaker.ThrowHeatGlow(this.Position, this.Map, 1f);
                    if (this.soundSustainer == null || this.soundSustainer.Ended)
                    {
                        SoundDef craftingSound = this.printerProperties.craftingSound;
                        if (craftingSound != null && craftingSound.sustain)
                        {
                            SoundInfo info = SoundInfo.InMap((TargetInfo)(Thing)this, MaintenanceType.PerTick);
                            this.soundSustainer = craftingSound.TrySpawnSustainer(info);
                        }
                    }
                }
                if (this.soundSustainer == null || this.soundSustainer.Ended)
                {
                    break;
                }
                this.soundSustainer.Maintain();
                break;

            default:
                if (this.soundSustainer == null || this.soundSustainer.Ended)
                {
                    break;
                }
                this.soundSustainer.End();
                break;
            }
        }
Example #12
0
 public static void StartupHibernatingParts(Building rootBuilding)
 {
     foreach (Building item in ShipBuildingsAttachedTo(rootBuilding).ToList())
     {
         CompHibernatable compHibernatable = item.TryGetComp <CompHibernatable>();
         if (compHibernatable != null && compHibernatable.State == HibernatableStateDefOf.Hibernating)
         {
             compHibernatable.Startup();
         }
     }
     SoundDefOf.ShipReactor_Startup.PlayOneShot(SoundInfo.InMap(rootBuilding));
 }
Example #13
0
        /// <summary>
        /// Impacts a pawn/object or the ground.
        /// </summary>
        protected override void Impact(Thing hitThing)
        {
            if (hitThing != null)
            {
                Map map = base.Map;
                BattleLogEntry_RangedImpact battleLogEntry_RangedImpact = new BattleLogEntry_RangedImpact(this.launcher,
                                                                                                          hitThing, this.intendedTarget.Thing, this.equipmentDef, this.def, this.targetCoverDef);
                Find.BattleLog.Add(battleLogEntry_RangedImpact);
                if (hitThing != null)
                {
                    int        damageAmountBase = this.def.projectile.GetDamageAmount(this.launcher);
                    DamageDef  damageDef        = this.def.projectile.damageDef;
                    int        amount           = damageAmountBase;
                    float      y            = this.ExactRotation.eulerAngles.y;
                    Thing      launcher     = this.launcher;
                    ThingDef   equipmentDef = this.equipmentDef;
                    DamageInfo dinfo        = new DamageInfo(damageDef, amount, this.ArmorPenetration, y, launcher, null, equipmentDef,
                                                             DamageInfo.SourceCategory.ThingOrUnknown);
                    hitThing.TakeDamage(dinfo).AssociateWithLog(battleLogEntry_RangedImpact);
                }
//                else
//                {
//                    SoundDefOf.BulletImpact_Ground.PlayOneShot(new TargetInfo(base.Position, map, false));
//                    MoteMaker.MakeStaticMote(this.ExactPosition, map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
//                    if (base.Position.GetTerrain(map).takeSplashes)
//                    {
//                        MoteMaker.MakeWaterSplash(this.ExactPosition, map, Mathf.Sqrt((float)this.def.projectile.GetDamageAmount(this.launcher) * 1f, 4f);
//                    }
//                }
                //int damageAmountBase = this.def.projectile.DamageAmount;
                //DamageInfo dinfo = new DamageInfo(this.def.projectile.damageDef, damageAmountBase, this.ExactRotation.eulerAngles.y, this.launcher, null, equipmentDef);
                //hitThing.TakeDamage(dinfo);
                //hitThing.TakeDamage(dinfo);
                if (this.canStartFire && Rand.Range(0f, 1f) > startFireChance)
                {
                    hitThing.TryAttachFire(0.05f);
                }
                Pawn pawn = hitThing as Pawn;
                if (pawn != null)
                {
                    PostImpactEffects(this.launcher as Pawn, pawn);
                    MoteMaker.ThrowMicroSparks(this.destination, this.Map);
                    MoteMaker.MakeStaticMote(this.destination, this.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                }
            }
            else
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, this.Map, false), MaintenanceType.None);
                SoundDefOf.BulletImpact_Ground.PlayOneShot(info);
                MoteMaker.MakeStaticMote(this.ExactPosition, this.Map, ThingDefOf.Mote_ShotHit_Dirt, 1f);
                MoteMaker.ThrowMicroSparks(this.ExactPosition, this.Map);
            }
        }
Example #14
0
        // helpers ==================================================================================

        static void CastEatingSound(Zombie zombie)
        {
            if (Constants.USE_SOUND && Prefs.VolumeAmbient > 0f)
            {
                var map = zombie.Map;
                if (map != null)
                {
                    var info = SoundInfo.InMap(new TargetInfo(zombie.Position, map, false));
                    SoundDef.Named("ZombieEating").PlayOneShot(info);
                }
            }
        }
 public void Setup()
 {
     if (!setup)
     {
         setup = true;
         if (!def.building.soundAmbient.NullOrUndefined() && sustainerAmbient == null)
         {
             var info = SoundInfo.InMap(this);
             sustainerAmbient = def.building.soundAmbient.TrySpawnSustainer(info);
         }
     }
 }
Example #16
0
        public void ApplyTechnoShield(Pawn pawn)
        {
            ApplyHediffs(pawn);
            SoundInfo info = SoundInfo.InMap(new TargetInfo(pawn.Position, pawn.Map, false), MaintenanceType.None);

            info.pitchFactor = .7f;
            SoundDefOf.EnergyShield_Reset.PlayOneShot(info);
            MoteMaker.ThrowLightningGlow(pawn.DrawPos, pawn.Map, 1.5f);
            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_TechnoShield"), pawn.DrawPos, pawn.Map, .3f, .2f, 0, .2f, Rand.Range(-500, 500), 0, 0, Rand.Range(0, 360));
            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_TechnoShield"), pawn.DrawPos, pawn.Map, .6f, .2f, .1f, .1f, Rand.Range(-500, 500), 0, 0, Rand.Range(0, 360));
            TM_MoteMaker.ThrowGenericMote(ThingDef.Named("Mote_TechnoShield"), pawn.DrawPos, pawn.Map, 1f, .2f, .2f, .05f, Rand.Range(-500, 500), 0, 0, Rand.Range(0, 360));
        }
        // Token: 0x060000FD RID: 253 RVA: 0x00009624 File Offset: 0x00007824
        protected void ImpactSomething()
        {
            bool flyOverhead = this.def.projectile.flyOverhead;

            if (flyOverhead)
            {
                RoofDef roofDef = base.Map.roofGrid.RoofAt(base.destinationInt.ToIntVec3());
                bool    flag    = roofDef != null && roofDef.isThickRoof;
                if (flag)
                {
                    SoundInfo soundInfo = SoundInfo.InMap(new TargetInfo(base.destinationInt.ToIntVec3(), base.Map, false), 0);
                    SoundStarter.PlayOneShot(this.def.projectile.soundHitThickRoof, soundInfo);
                    return;
                }
            }
            bool flag2 = this.intendedTarget != null;

            if (flag2)
            {
                Pawn pawn  = this.intendedTarget as Pawn;
                bool flag3 = pawn != null && pawn.Downed && (this.origin - this.Destination).magnitude > 5f && Rand.Value < 0.2f;
                if (flag3)
                {
                    this.Impact(null);
                }
                else
                {
                    this.Impact(this.intendedTarget);
                }
            }
            else
            {
                Thing thing = base.Map.thingGrid.ThingAt(base.destinationInt.ToIntVec3(), (ThingCategory)1);
                bool  flag4 = thing != null;
                if (flag4)
                {
                    this.Impact(thing);
                }
                else
                {
                    foreach (Thing thing2 in base.Map.thingGrid.ThingsAt(base.destinationInt.ToIntVec3()))
                    {
                        bool flag5 = thing2.def.fillPercent > 0f || thing2.def.passability > 0;
                        if (flag5)
                        {
                            this.Impact(thing2);
                            return;
                        }
                    }
                    this.Impact(null);
                }
            }
        }
        /// <summary>
        ///     Computes what should be impacted in the DestinationCell.
        /// </summary>
        protected void ImpactSomething()
        {
            // Check impact on a thick mountain.
            if (def.projectile.flyOverhead)
            {
                var roofDef = Map.roofGrid.RoofAt(DestinationCell);
                if (roofDef != null && roofDef.isThickRoof)
                {
                    if (def.projectile != null)
                    {
                        if (def.projectile.soundHitThickRoof != null)
                        {
                            var info = SoundInfo.InMap(new TargetInfo(DestinationCell, Map, false),
                                                       MaintenanceType.None);
                            def.projectile.soundHitThickRoof.PlayOneShot(info);
                            return;
                        }
                    }
                }
            }

            // Impact the initial targeted pawn.
            if (intendedTarget != null)
            {
                if (intendedTarget.Thing is Pawn pawn && pawn.Downed && (origin - destination).magnitude > 5f &&
                    Rand.Value < 0.2f)
                {
                    Impact(null);
                    return;
                }
                Impact(intendedTarget.Thing);
            }
            else
            {
                // Impact a pawn in the destination cell if present.
                var thing = Map.thingGrid.ThingAt(DestinationCell, ThingCategory.Pawn);
                if (thing != null)
                {
                    Impact(thing);
                    return;
                }
                // Impact any cover object.
                foreach (var current in Map.thingGrid.ThingsAt(DestinationCell))
                {
                    if (current.def.fillPercent > 0f || current.def.passability != Traversability.Standable)
                    {
                        Impact(current);
                        return;
                    }
                }
                Impact(null);
            }
        }
Example #19
0
 public void Setup()
 {
     if (!setup)
     {
         setup = true;
         if (!this.def.building.soundAmbient.NullOrUndefined() && this.sustainerAmbient == null)
         {
             SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None);
             this.sustainerAmbient = this.def.building.soundAmbient.TrySpawnSustainer(info);
         }
     }
 }
Example #20
0
 public void PlaySustainer()
 {
     if (sustainer == null || sustainer.Ended)
     {
         var soundInfo = SoundInfo.InMap(new TargetInfo(this), MaintenanceType.PerTick);
         sustainer = SoundOfCurrentRecipe.TrySpawnSustainer(soundInfo);
     }
     else
     {
         sustainer.Maintain();
     }
 }
        // Token: 0x060024B9 RID: 9401 RVA: 0x00117A10 File Offset: 0x00115E10
        public override void EjectContents()
        {
            List <Thing> list = new List <Thing>();

            if (!this.contentsKnown)
            {
                list.AddRange(this.innerContainer);
                list.AddRange(this.UnopenedCasketsInGroup().SelectMany((Building_XenomorphCryptosleepCasket c) => c.innerContainer));
            }
            bool     contentsKnown = this.contentsKnown;
            ThingDef filth_Slime   = ThingDefOf.Filth_Slime;

            foreach (Thing thing in ((IEnumerable <Thing>) this.innerContainer))
            {
                if (thing is Pawn pawn)
                {
                    PawnComponentsUtility.AddComponentsForSpawn(pawn);
                    pawn.filth.GainFilth(filth_Slime);
                    if (pawn.RaceProps.IsFlesh)
                    {
                        pawn.health.AddHediff(HediffDefOf.CryptosleepSickness, null, null, null);
                    }
                }
            }
            if (!base.Destroyed)
            {
                SoundDefOf.CryptosleepCasket_Eject.PlayOneShot(SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.None));
            }
            this.innerContainer.TryDropAll(this.InteractionCell, base.Map, ThingPlaceMode.Near, null, (x => GridsUtility.GetFirstBuilding(x, this.Map) == null));
            this.contentsKnown = true;
            if (!contentsKnown)
            {
                //    ThingDef filth_Slime = ThingDefOf.Filth_Slime;
                FilthMaker.TryMakeFilth(base.Position, base.Map, filth_Slime, Rand.Range(8, 12));
                this.SetFaction(null, null);

                /*
                 * foreach (Building_XenomorphCryptosleepCasket building_AncientCryptosleepCasket in this.UnopenedCasketsInGroup())
                 * {
                 *  building_AncientCryptosleepCasket.EjectContents();
                 * }
                 */
                List <Pawn>        source     = list.OfType <Pawn>().ToList <Pawn>();
                IEnumerable <Pawn> enumerable = from p in source
                                                where p.RaceProps.Humanlike && p.GetLord() == null && p.Faction == Faction.OfAncientsHostile
                                                select p;
                if (enumerable.Any <Pawn>())
                {
                    LordMaker.MakeNewLord(Faction.OfAncientsHostile, new LordJob_AssaultColony(Faction.OfAncientsHostile, false, false, false, false, false), base.Map, enumerable);
                }
            }
        }
        public override string LabelNoCount => "occult " + GenLabel.ThingLabel(this, 1);         // Doesn't work!

        // Make it harder to extinguish

        //---------------------------

        public override void Tick()
        {
            ticksSinceSpawn++;

            // Probably the best way is to use reflection and modify base class field [ticksSinceSpawn]
            // [ticksSinceSpawn] is used in [ExposeData] and [Rimworld.Verb_BeatFire]
            // Vanilla code passes fire as [Fire] class, therefore it's important to [ticksSinceSpawn] variable
            FieldInfo fieldInfo = typeof(Fire).GetField("ticksSinceSpawn", BindingFlags.Instance | BindingFlags.NonPublic);

            fieldInfo.SetValue(this as Fire, ticksSinceSpawn);

            if (lastFireCountUpdateTick != Find.TickManager.TicksGame)
            {
                fireCount = base.Map.listerThings.ThingsOfDef(def).Count;
                lastFireCountUpdateTick = Find.TickManager.TicksGame;
            }
            if (sustainer != null)
            {
                sustainer.Maintain();
            }
            else if (!base.Position.Fogged(base.Map))
            {
                SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map), MaintenanceType.PerTick);
                sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, SoundDefOf.FireBurning, info);
            }
            ticksUntilSmoke--;
            if (ticksUntilSmoke <= 0)
            {
                //SpawnSmokeParticles();
            }
            if (fireCount < 15 && fireSize > 0.7f && Rand.Value < fireSize * 0.01f)
            {
                MoteMaker.ThrowMicroSparks(DrawPos, base.Map);
            }
            if (fireSize > 1f)
            {
                ticksSinceSpread++;
                if ((float)ticksSinceSpread >= SpreadInterval)
                {
                    TrySpread();
                    ticksSinceSpread = 0;
                }
            }
            if (this.IsHashIntervalTick(150))
            {
                DoComplexCalcs();
            }
            if (ticksSinceSpawn >= 7500)
            {
                TryBurnFloor();
            }
        }
Example #23
0
        private Toil Toils_Training(TargetIndex targetIndex)
        {
            Toil toil = new Toil();

            toil.initAction = (Action)(() =>
            {
                toil.actor.pather.StopDead();
                Building_Trainable X = (Building_Trainable)this.TargetA;

                switch (X.def.defName)
                {
                case "ShootingRange":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    IntVec3 shooter = TargetA.Cell + IntVec3Utility.RotatedBy(new Vector3(0.0f, 0.0f, 3f).ToIntVec3(), X.Rotation);
                    Projectile projectile = (Projectile)ThingMaker.MakeThing(ThingDef.Named("TrainingBullet"), (ThingDef)null);
                    GenSpawn.Spawn((Thing)projectile, pawn.Position, Map);
                    projectile.Launch((Thing)pawn, pawn.DrawPos, shooter, (Thing)null);

                    SoundDef Sound_shoot = SoundDef.Named("ShotRevolver");
                    Sound_shoot.PlayOneShot(SoundInfo.InMap(X, MaintenanceType.None));
                    break;

                case "CPRdummy":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    MoteMaker.ThrowMetaIcon(this.TargetA.Cell, this.Map, ThingDef.Named("Mote_HealingCross"));
                    break;

                case "Holodeck":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    IntVec3 bubble_pos = new IntVec3(TargetA.Cell.x + 1, TargetA.Cell.y, TargetA.Cell.z);

                    MoteMaker.MakeStaticMote(bubble_pos, Map, DefDatabase <ThingDef> .GetNamed("Mote_Speech"), 1f);
                    break;

                case "PunchingBag":
                    this.pawn.skills.Learn(DefDatabase <SkillDef> .GetNamed(X.TrainingType, true), XPgain);

                    MoteMaker.ThrowDustPuff(TargetA.Cell, Map, 1.0f);

                    SoundDef Sound_PBAG = SoundDef.Named("Pawn_Melee_Punch_HitPawn");
                    Sound_PBAG.PlayOneShot(SoundInfo.InMap(X, MaintenanceType.None));
                    break;

                default: return;
                }
            });
            toil.defaultCompleteMode = ToilCompleteMode.Instant;
            return(toil);
        }
Example #24
0
        public virtual void Launch(Thing launcher, Vector2 origin, Thing equipment = null)
        {
            this.launcher = launcher;
            this.origin   = origin;
            //For explosives/bullets, equipmentDef is important
            equipmentDef = (equipment != null) ? equipment.def : null;

            if (!def.projectile.soundAmbient.NullOrUndefined())
            {
                var info = SoundInfo.InMap(this, MaintenanceType.PerTick);
                ambientSustainer = def.projectile.soundAmbient.TrySpawnSustainer(info);
            }
        }
Example #25
0
        // Token: 0x06000020 RID: 32 RVA: 0x00002BF0 File Offset: 0x00000DF0
        public override void CompTickRare()
        {
            if (!parent.Spawned || parent.Position.Roofed(parent.Map))
            {
                return;
            }

            var SInfo = SoundInfo.InMap(parent);

            SoundDefOf.Roof_Collapse.PlayOneShot(SInfo);
            FilthMaker.TryMakeFilth(parent.Position, parent.Map, ThingDefOf.Filth_RubbleBuilding);
            parent.Destroy();
        }
        public virtual void Launch(Thing launcher, Vector2 origin, Thing equipment = null)
        {
            this.shotSpeed = def.projectile.speed;
            this.launcher  = launcher;
            this.origin    = origin;
            equipmentDef   = (equipment != null) ? equipment.def : null;

            if (!def.projectile.soundAmbient.NullOrUndefined())
            {
                SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
                ambientSustainer = def.projectile.soundAmbient.TrySpawnSustainer(info);
            }
        }
Example #27
0
 public override void SpawnSetup(Map map, bool respawningAfterLoad)
 {
     base.SpawnSetup(map, respawningAfterLoad);
     this.RecalcPathsOnAndAroundMe(map);
     LessonAutoActivator.TeachOpportunity(ConceptDefOf.HomeArea, this, OpportunityType.Important);
     this.ticksSinceSpread = (int)(this.SpreadInterval * Rand.Value);
     LongEventHandler.ExecuteWhenFinished(delegate
     {
         SoundDef def   = SoundDef.Named("FireBurning");
         SoundInfo info = SoundInfo.InMap(new TargetInfo(this.Position, map, false), MaintenanceType.PerTick);
         this.sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, def, info);
     });
 }
Example #28
0
 // Token: 0x0600264C RID: 9804 RVA: 0x00123070 File Offset: 0x00121470
 public override void Tick()
 {
     this.ticksSinceSpawn++;
     if (Warpfire.lastFireCountUpdateTick != Find.TickManager.TicksGame)
     {
         Warpfire.fireCount = base.Map.listerThings.ThingsOfDef(this.def).Count;
         Warpfire.lastFireCountUpdateTick = Find.TickManager.TicksGame;
     }
     if (this.sustainer != null)
     {
         this.sustainer.Maintain();
     }
     else if (!base.Position.Fogged(base.Map))
     {
         SoundInfo info = SoundInfo.InMap(new TargetInfo(base.Position, base.Map, false), MaintenanceType.PerTick);
         this.sustainer = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor(this, SoundDefOf.FireBurning, info);
     }
     this.ticksUntilSmoke--;
     if (this.ticksUntilSmoke <= 0)
     {
         this.SpawnSmokeParticles();
     }
     if (Warpfire.fireCount < 15 && this.fireSize > 0.7f && Rand.Value < this.fireSize * 0.01f)
     {
         ThrowMicroSparks(this.DrawPos, base.Map);
     }
     if (this.fireSize > 1f)
     {
         this.ticksSinceSpread++;
         if ((float)this.ticksSinceSpread >= this.SpreadInterval)
         {
             this.TrySpread();
             this.ticksSinceSpread = 0;
         }
     }
     if (this.IsHashIntervalTick(150))
     {
         this.DoComplexCalcs();
     }
     if (this.ticksSinceSpawn >= 7500)
     {
         this.TryBurnFloor();
     }
     if (this.IsHashIntervalTick(150))
     {
         if (Rand.Chance(0.25f) && this.Spawned)
         {
             this.DeSpawn();
         }
     }
 }
Example #29
0
        public static bool Tick(Fire __instance)
        {
            Map map = __instance.Map;

            if (null != map)
            {
                ++ticksSinceSpawn(__instance);
                if (lastFireCountUpdateTick != Find.TickManager.TicksGame)
                {
                    fireCount = __instance.Map.listerThings.ThingsOfDef(__instance.def).Count;
                    lastFireCountUpdateTick = Find.TickManager.TicksGame;
                }
                if (sustainer(__instance) != null)
                {
                    sustainer(__instance).Maintain();
                }
                else if (!__instance.Position.Fogged(__instance.Map))
                {
                    SoundInfo info = SoundInfo.InMap(new TargetInfo(__instance.Position, __instance.Map, false), MaintenanceType.PerTick);
                    sustainer(__instance) = SustainerAggregatorUtility.AggregateOrSpawnSustainerFor((ISizeReporter)__instance, SoundDefOf.FireBurning, info);
                }
                --ticksUntilSmoke(__instance);
                if (ticksUntilSmoke(__instance) <= 0)
                {
                    SpawnSmokeParticles(__instance);
                }
                if (fireCount < 15 && (double)__instance.fireSize > 0.699999988079071 && (double)Rand.Value < (double)__instance.fireSize * 0.00999999977648258)
                {
                    MoteMaker.ThrowMicroSparks(__instance.DrawPos, __instance.Map);
                }
                if ((double)__instance.fireSize > 1.0)
                {
                    ++ticksSinceSpread(__instance);
                    if ((double)ticksSinceSpread(__instance) >= (double)get_SpreadInterval(__instance))
                    {
                        TrySpread(__instance);
                        ticksSinceSpread(__instance) = 0;
                    }
                }
                if (__instance.IsHashIntervalTick(150))
                {
                    DoComplexCalcs(__instance);
                }
                if (ticksSinceSpawn(__instance) < 7500)
                {
                    return(false);
                }
                TryBurnFloor(__instance);
            }
            return(false);
        }
Example #30
0
        public override void SpawnSetup(Map map, bool respawningAfterLoad)
        {
            if (this.def.IsEdifice())
            {
                map.edificeGrid.Register(this);
            }
            base.SpawnSetup(map, respawningAfterLoad);
            base.Map.listerBuildings.Add(this);
            if (this.def.coversFloor)
            {
                base.Map.mapDrawer.MapMeshDirty(base.Position, MapMeshFlag.Terrain, true, false);
            }
            CellRect cellRect = this.OccupiedRect();

            for (int i = cellRect.minZ; i <= cellRect.maxZ; i++)
            {
                for (int j = cellRect.minX; j <= cellRect.maxX; j++)
                {
                    IntVec3 intVec = new IntVec3(j, 0, i);
                    base.Map.mapDrawer.MapMeshDirty(intVec, MapMeshFlag.Buildings);
                    base.Map.glowGrid.MarkGlowGridDirty(intVec);
                    if (!SnowGrid.CanCoexistWithSnow(this.def))
                    {
                        base.Map.snowGrid.SetDepth(intVec, 0f);
                    }
                }
            }
            if (base.Faction == Faction.OfPlayer)
            {
                if (this.def.building != null && this.def.building.spawnedConceptLearnOpportunity != null)
                {
                    LessonAutoActivator.TeachOpportunity(this.def.building.spawnedConceptLearnOpportunity, OpportunityType.GoodToKnow);
                }
            }
            AutoHomeAreaMaker.Notify_BuildingSpawned(this);
            if (this.def.building != null && !this.def.building.soundAmbient.NullOrUndefined())
            {
                LongEventHandler.ExecuteWhenFinished(delegate
                {
                    SoundInfo info        = SoundInfo.InMap(this, MaintenanceType.None);
                    this.sustainerAmbient = this.def.building.soundAmbient.TrySpawnSustainer(info);
                });
            }
            base.Map.listerBuildingsRepairable.Notify_BuildingSpawned(this);
            if (!this.CanBeSeenOver())
            {
                base.Map.exitMapGrid.Notify_LOSBlockerSpawned();
            }
            SmoothSurfaceDesignatorUtility.Notify_BuildingSpawned(this);
        }