Example #1
0
 public override void PostDeSpawn(Map map)
 {
     if (sustainer != null)
     {
         sustainer.End();
     }
 }
Example #2
0
 protected void StartJetting()
 {
     JState         = JetterState.Jetting;
     TicksUntilMove = 3;
     wickSoundSustainer.End();
     wickSoundSustainer = null;
     wickSoundSustainer = SoundDefOf.HissJet.TrySpawnSustainer(this);
 }
Example #3
0
 private void EndSpray()
 {
     if (spraySustainer != null)
     {
         spraySustainer.End();
         spraySustainer = null;
     }
 }
 public override void PostDeSpawn(Map map)
 {
     base.PostDeSpawn(map);
     if (sustainer != null && !sustainer.Ended)
     {
         sustainer.End();
     }
 }
        public override void ExtraCrafterTickAction()
        {
            if (!powerComp.PowerOn && soundSustainer != null && !soundSustainer.Ended)
            {
                soundSustainer.End();
            }

            //Make construction effects
            switch (crafterStatus)
            {
            case CrafterStatus.Filling:
                //Emit smoke
                if (powerComp.PowerOn && Current.Game.tickManager.TicksGame % 300 == 0)
                {
                    MoteMaker.ThrowSmoke(Position.ToVector3(), Map, 1f);
                }
                break;

            case CrafterStatus.Crafting:
                //Emit smoke
                if (powerComp.PowerOn && Current.Game.tickManager.TicksGame % 100 == 0)
                {
                    for (int i = 0; i < 5; i++)
                    {
                        MoteMaker.ThrowMicroSparks(Position.ToVector3() + new Vector3(Rand.Range(-1, 1), 0f, Rand.Range(-1, 1)), Map);
                    }
                    for (int i = 0; i < 3; i++)
                    {
                        MoteMaker.ThrowSmoke(Position.ToVector3() + new Vector3(Rand.Range(-1f, 1f), 0f, Rand.Range(-1f, 1f)), Map, Rand.Range(0.5f, 0.75f));
                    }
                    MoteMaker.ThrowHeatGlow(Position, Map, 1f);

                    if (soundSustainer == null || soundSustainer.Ended)
                    {
                        SoundDef soundDef = printerProperties.craftingSound;
                        if (soundDef != null && soundDef.sustain)
                        {
                            SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick);
                            soundSustainer = soundDef.TrySpawnSustainer(info);
                        }
                    }
                }
                if (soundSustainer != null && !soundSustainer.Ended)
                {
                    soundSustainer.Maintain();
                }
                break;

            default:
            {
                if (soundSustainer != null && !soundSustainer.Ended)
                {
                    soundSustainer.End();
                }
            }
            break;
            }
        }
 public override void PostDeSpawn(Map map)
 {
     base.PostDeSpawn(map);
     map.info.parent.Notify_HibernatableChanged();
     if (sustainer != null && !sustainer.Ended)
     {
         sustainer.End();
     }
 }
Example #7
0
 public void DoTickWork()
 {
     if (isQuiet)
     {
         return;
     }
     ticksUntilQuiet--;
     if (ticksUntilQuiet <= 0)
     {
         isQuiet = true;
         sustainerAmbient.End();
     }
 }
Example #8
0
        public override void Tick()
        {
            if (Spawned)
            {
                sustainer.Maintain();
                Vector3 vector = Position.ToVector3Shifted();
                IntVec3 c;
                if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 5.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(Position, Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999))
                {
                    FilthMaker.TryMakeFilth(c, Map, RatkinTunnelUtility.filthTypes.RandomElement <ThingDef>(), 1);
                }

                if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
                {
                    MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
                    {
                        y = AltitudeLayer.MoteOverhead.AltitudeFor()
                    }, Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
                }
                if (secondarySpawnTick <= Find.TickManager.TicksGame)
                {
                    sustainer.End();
                    Map     map      = Map;
                    IntVec3 position = Position;
                    Destroy(DestroyMode.Vanish);
                    if (spawnTunnel)
                    {
                        Building_ThiefTunnel tunnel = (Building_ThiefTunnel)GenSpawn.Spawn(ThingMaker.MakeThing(RatkinBuildingDefOf.RK_ThiefTunnel, null), position, map, WipeMode.Vanish);
                        tunnel.SetFaction(Find.FactionManager.FirstFactionOfDef(RatkinFactionDefOf.Rakinia), null);
                    }
                }
            }
        }
Example #9
0
        private void DoTickWork()
        {
            if (isQuiet)
            {
                return;
            }

            ticksUntilQuiet--;
            if (ticksUntilQuiet > 0)
            {
                return;
            }

            isQuiet = true;
            sustainerAmbient.End();
        }
Example #10
0
        private static void RecreateMapSustainers()
        {
            if (!AltitudeWindSoundCreated)
            {
                SoundDefOf.Ambient_AltitudeWind.TrySpawnSustainer(SoundInfo.OnCamera());
            }
            SustainerManager sustainerManager = Find.SoundRoot.sustainerManager;

            for (int i = 0; i < biomeAmbientSustainers.Count; i++)
            {
                Sustainer sustainer = biomeAmbientSustainers[i];
                if (sustainerManager.AllSustainers.Contains(sustainer) && !sustainer.Ended)
                {
                    sustainer.End();
                }
            }
            biomeAmbientSustainers.Clear();
            if (Find.CurrentMap != null)
            {
                List <SoundDef> soundsAmbient = Find.CurrentMap.Biome.soundsAmbient;
                for (int j = 0; j < soundsAmbient.Count; j++)
                {
                    Sustainer item = soundsAmbient[j].TrySpawnSustainer(SoundInfo.OnCamera());
                    biomeAmbientSustainers.Add(item);
                }
            }
        }
Example #11
0
 private void EndWickSustainer()
 {
     if (wickSoundSustainer != null)
     {
         wickSoundSustainer.End();
         wickSoundSustainer = null;
     }
 }
Example #12
0
 private void EndSustainer()
 {
     if (sustainer != null)
     {
         sustainer.End();
         sustainer = null;
     }
 }
        private void StopFireLaser()
        {
            beam.IsActive = false;
            soundSustainer?.End();

            // Turn off glow.
            CompGlower?.ReceiveCompSignal("PowerTurnedOn");
        }
 private void EndSustainerPoweredIfActive()
 {
     if (sustainerPowered != null)
     {
         sustainerPowered.End();
         sustainerPowered = null;
     }
 }
Example #15
0
        private void StopSustainer()
        {
            if (skiddingSustainer == null)
            {
                return;
            }

            skiddingSustainer.End();
            skiddingSustainer = null;
        }
Example #16
0
        private void StopSustainer()
        {
            if (sustainer == null || Props.ambiance == "None")
            {
                return;
            }

            sustainer.End();
            sustainer = null;
        }
        private void StopSustainerHot()
        {
            if (sustainerHot == null)
            {
                return;
            }

            sustainerHot.End();
            sustainerHot = null;
        }
Example #18
0
 public void EndDrag()
 {
     dragging                = false;
     lastDragRealTime        = -99999f;
     lastFrameDragCellsDrawn = 0;
     if (sustainer != null)
     {
         sustainer.End();
         sustainer = null;
     }
 }
Example #19
0
 public override void CompTick()
 {
     base.CompTick();
     if (sustainer != null)
     {
         sustainer.Maintain();
         if (TicksLeft < fadeOutDuration)
         {
             sustainer.End();
             sustainer = null;
         }
     }
 }
Example #20
0
 public override void Destroy(DestroyMode mode = DestroyMode.Vanish)
 {
     base.Destroy(mode);
     if (wickSoundSustainer != null)
     {
         wickSoundSustainer.End();
         wickSoundSustainer = null;
     }
     if (jetSoundSustainer != null)
     {
         jetSoundSustainer.End();
         jetSoundSustainer = null;
     }
 }
        public static bool EndAllInMap(SustainerManager __instance, Map map)
        {
            List <Sustainer> snapshotAllSustainers = __instance.AllSustainers;

            for (int index = 0; index < snapshotAllSustainers.Count; index++)
            {
                Sustainer sustainer = snapshotAllSustainers[index];
                if (sustainer.info.Maker.Map == map)
                {
                    sustainer.End();
                }
            }
            return(false);
        }
        public void MuteToggle()
        {
            this.isMuted = !this.isMuted;
            if (isMuted)
            {
                Sustainer sustainer = (Sustainer)typeof(Building).GetField("sustainerAmbient", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);
                sustainer.End();
            }
            else
            {
                Sustainer sustainer = (Sustainer)typeof(Building).GetField("sustainerAmbient", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);

                SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None);
                sustainer = new Sustainer(this.def.building.soundAmbient, info);
            }
        }
Example #23
0
        public override void Tick()
        {
            if (Spawned)
            {
                sustainer.Maintain();
                Vector3 vector = Position.ToVector3Shifted();
                IntVec3 c;
                if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(Position, Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors, Danger.Deadly, false), null, null, out c, 999999))
                {
                    FilthMaker.MakeFilth(c, Map, filthTypes.RandomElement(), 1);
                }
                if (Rand.MTBEventOccurs(DustMoteSpawnMTB, 1f, 1.TicksToSeconds()))
                {
                    MoteMaker.ThrowDustPuffThick(new Vector3(vector.x, 0f, vector.z)
                    {
                        y = AltitudeLayer.MoteOverhead.AltitudeFor()
                    }, Map, Rand.Range(1.5f, 3f), new Color(1f, 1f, 1f, 2.5f));
                }
                if (secondarySpawnTick <= Find.TickManager.TicksGame)
                {
                    sustainer.End();
                    Map     map      = Map;
                    IntVec3 position = Position;
                    Destroy(DestroyMode.Vanish);

                    if (faction == null)
                    {
                        faction = HiveUtility.GetRandomInsectFaction();
                    }
                    PawnKindDef kindDef = HiveUtility.GetFactionKindDef(PawnKindDef.Named("BI_Megascarab_Brown"), faction);
                    Insect      insect  = PawnGenerator.GeneratePawn(kindDef, faction) as Insect;
                    insect.stealFood = true;
                    GenSpawn.Spawn(insect, CellFinder.RandomClosewalkCellNear(position, map, 4, null), map);
                    if (queen != null)
                    {
                        queen.spawnedInsects.Add(insect);
                        Lord lord = queen.Lord;
                        if (lord == null)
                        {
                            lord = queen.CreateNewLord();
                        }
                        lord.AddPawn(insect);
                    }
                }
            }
        }
Example #24
0
 public void ResolveMovementSound()
 {
     if (parent is Pawn p && Props.soundMoving != null)
     {
         var isMovingNow = p?.pather?.Moving ?? false;
         if (isMovingNow && movingSustainer == null)
         {
             var info = SoundInfo.InMap(parent, MaintenanceType.None);
             movingSustainer = Props.soundMoving.TrySpawnSustainer(info);
         }
         else if (!isMovingNow && movingSustainer != null)
         {
             movingSustainer.End();
             movingSustainer = null;
         }
     }
 }
Example #25
0
 public void DoEditWidgets(WidgetRow widgetRow)
 {
     if (testSustainer == null)
     {
         if (!widgetRow.ButtonIcon(TexButton.Play))
         {
             return;
         }
         ResolveReferences();
         SoundInfo info;
         if (HasSubSoundsInWorld)
         {
             IntVec3 mapPosition = Find.CameraDriver.MapPosition;
             info = SoundInfo.InMap(new TargetInfo(mapPosition, Find.CurrentMap), MaintenanceType.PerFrame);
             for (int i = 0; i < 5; i++)
             {
                 MoteMaker.ThrowDustPuff(mapPosition, Find.CurrentMap, 1.5f);
             }
         }
         else
         {
             info = SoundInfo.OnCamera(MaintenanceType.PerFrame);
         }
         info.testPlay = true;
         if (sustain)
         {
             testSustainer = this.TrySpawnSustainer(info);
         }
         else
         {
             this.PlayOneShot(info);
         }
     }
     else
     {
         testSustainer.Maintain();
         if (widgetRow.ButtonIcon(TexButton.Stop))
         {
             testSustainer.End();
             testSustainer = null;
         }
     }
 }
        public static bool RecreateMapSustainers()
        {
            if (!(bool)altitudeWindSoundCreatedPI.GetValue(null))
            {
                SoundDefOf.Ambient_AltitudeWind.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
            }
            SustainerManager sustainerManager = Find.SoundRoot.sustainerManager;
            List <Sustainer> sustainers       = (biomeAmbientSustainersFI.GetValue(null) as List <Sustainer>);

            //lock (sustainerManager.AllSustainers)
            //{
            foreach (Sustainer s in sustainers)
            {
                if (sustainerManager.AllSustainers.Contains(s) && !s.Ended)
                {
                    s.End();
                }
            }
            sustainers.Clear();
            if (Find.CurrentMap != null)
            {
                List <SoundDef> soundsAmbient = Find.CurrentMap.Biome.soundsAmbient;
                for (int j = 0; j < soundsAmbient.Count; j++)
                {
                    Sustainer item = soundsAmbient[j].TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
                    try
                    {
                        lock (sustainerManager.AllSustainers)
                        {
                            sustainerManager.AllSustainers.Add(item);
                        }
                    }
                    catch (Exception)
                    {
                        item.End();
                    }
                }
            }
            //}
            return(false);
        }
Example #27
0
        public void DealWithAudio()
        {
            if (Props.pingSound != null && beaconStatus == EnhancedBeaconStatus.Active && EnhancedBeaconMod.mod.settings.pingSound)
            {
                if (pingTick <= 0)
                {
                    SoundStarter.PlayOneShot(Props.pingSound, SoundInfo.InMap(this.parent));
                    pingTick = 3000;
                }
                else
                {
                    pingTick--;
                }
            }

            if (beaconStatus == EnhancedBeaconStatus.Active && !compPowerTrader.PowerOn)
            {
                if (Props.shutdownSound != null)
                {
                    SoundStarter.PlayOneShot(Props.shutdownSound, SoundInfo.InMap(this.parent));
                }
                if (ambientSustainer != null)
                {
                    ambientSustainer.End();
                }
                beaconStatus = EnhancedBeaconStatus.Inactive;
            }
            else if (beaconStatus == EnhancedBeaconStatus.Inactive && compPowerTrader.PowerOn)
            {
                if (Props.startupSound != null)
                {
                    SoundStarter.PlayOneShot(Props.startupSound, SoundInfo.InMap(this.parent));
                }
                if (Props.ambientSound != null)
                {
                    ambientSustainer = Props.ambientSound.TrySpawnSustainer(SoundInfo.InMap(this.parent));
                }
                beaconStatus = EnhancedBeaconStatus.Active;
            }
        }
        public void Dismount()
        {
            Building_Reloadable turret = (parent as Building_Reloadable);

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

            if (Driver.RaceProps.Humanlike)
            {
                Driver.AllComps?.Remove(driverComp);
                driverComp.vehicle = null;
                driverComp.parent  = null;
            }

            MapComponent_ToolsForHaul.currentVehicle.Remove(Driver);

            Driver.RaceProps.makesFootprints = true;

            //if (Find.Reservations.IsReserved(parent, Driver.Faction))
            Find.Reservations.ReleaseAllForTarget(parent);
            if (Driver.Faction != Faction.OfPlayer)
            {
                parent.SetForbidden(true);
                parent.SetFaction(null);
            }

            Driver = null;

            if (sustainerAmbient != null)
            {
                sustainerAmbient.End();
            }


            //  Find.ListerBuildings.Add(parent as Building);
        }
Example #29
0
        IEnumerator TickTasks()
        {
            var sw = new Stopwatch();

            sw.Start();
            RepositionColonists();
            yield return(null);

            HandleIncidents();
            yield return(null);

            FetchAvoidGrid();
            yield return(null);

            RecalculateVisibleMap();
            yield return(null);

            IncreaseZombiePopulation();
            yield return(null);

            UpdateZombieAvoider();
            yield return(null);

            ExecuteExplosions();
            yield return(null);

            var volume = 0f;

            if (allZombiesCached.Any())
            {
                var hour = GenLocalDate.HourFloat(Find.CurrentMap);
                if (hour < 12f)
                {
                    hour += 24f;
                }
                if (hour > Constants.HOUR_START_OF_NIGHT && hour < Constants.HOUR_END_OF_NIGHT)
                {
                    volume = 1f;
                }
                else if (hour >= Constants.HOUR_START_OF_DUSK && hour <= Constants.HOUR_START_OF_NIGHT)
                {
                    volume = GenMath.LerpDouble(Constants.HOUR_START_OF_DUSK, Constants.HOUR_START_OF_NIGHT, 0f, 1f, hour);
                }
                else if (hour >= Constants.HOUR_END_OF_NIGHT && hour <= Constants.HOUR_START_OF_DAWN)
                {
                    volume = GenMath.LerpDouble(Constants.HOUR_END_OF_NIGHT, Constants.HOUR_START_OF_DAWN, 1f, 0f, hour);
                }
            }
            yield return(null);

            if (Constants.USE_SOUND && ZombieSettings.Values.playCreepyAmbientSound)
            {
                if (zombiesAmbientSound == null)
                {
                    zombiesAmbientSound = CustomDefs.ZombiesClosingIn.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None));
                }

                if (volume < zombiesAmbientSoundVolume)
                {
                    zombiesAmbientSoundVolume -= 0.0001f;
                }
                else if (volume > zombiesAmbientSoundVolume)
                {
                    zombiesAmbientSoundVolume += 0.0001f;
                }
                zombiesAmbientSound.info.volumeFactor = zombiesAmbientSoundVolume;
            }
            else
            {
                if (zombiesAmbientSound != null)
                {
                    zombiesAmbientSound.End();
                    zombiesAmbientSound = null;
                }
            }
            yield return(null);

            if (colonistsConverter.Count > 0)
            {
                var pawn = colonistsConverter.Dequeue();
                Tools.ConvertToZombie(pawn);
            }
            yield return(null);
        }
Example #30
0
 public override void Tick()
 {
     if (base.Spawned)
     {
         sustainer.Maintain();
         Vector3 vector = base.Position.ToVector3Shifted();
         if (Rand.MTBEventOccurs(FilthSpawnMTB, 1f, 1.TicksToSeconds()) && CellFinder.TryFindRandomReachableCellNear(base.Position, base.Map, FilthSpawnRadius, TraverseParms.For(TraverseMode.NoPassClosedDoors), null, null, out IntVec3 result))
         {
             FilthMaker.MakeFilth(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), new Color(1f, 1f, 1f, 2.5f));
         }
         if (secondarySpawnTick <= Find.TickManager.TicksGame)
         {
             sustainer.End();
             Map     map      = base.Map;
             IntVec3 position = base.Position;
             Destroy();
             if (spawnHive)
             {
                 Hive hive = (Hive)GenSpawn.Spawn(ThingMaker.MakeThing(ThingDefOf.Hive), position, map);
                 hive.SetFaction(Faction.OfInsects);
                 foreach (CompSpawner comp in hive.GetComps <CompSpawner>())
                 {
                     if (comp.PropsSpawner.thingToSpawn == ThingDefOf.InsectJelly)
                     {
                         comp.TryDoSpawn();
                         break;
                     }
                 }
             }
             if (insectsPoints > 0f)
             {
                 insectsPoints = Mathf.Max(insectsPoints, Hive.spawnablePawnKinds.Min((PawnKindDef x) => x.combatPower));
                 float       pointsLeft = insectsPoints;
                 List <Pawn> list       = new List <Pawn>();
                 int         num        = 0;
                 while (pointsLeft > 0f)
                 {
                     num++;
                     if (num > 1000)
                     {
                         Log.Error("Too many iterations.");
                         break;
                     }
                     IEnumerable <PawnKindDef> source = from x in Hive.spawnablePawnKinds
                                                        where x.combatPower <= pointsLeft
                                                        select x;
                     if (!source.TryRandomElement(out PawnKindDef result2))
                     {
                         break;
                     }
                     Pawn pawn = PawnGenerator.GeneratePawn(result2, Faction.OfInsects);
                     GenSpawn.Spawn(pawn, CellFinder.RandomClosewalkCellNear(position, map, 2), map);
                     pawn.mindState.spawnedByInfestationThingComp = spawnedByInfestationThingComp;
                     list.Add(pawn);
                     pointsLeft -= result2.combatPower;
                 }
                 if (list.Any())
                 {
                     LordMaker.MakeNewLord(Faction.OfInsects, new LordJob_AssaultColony(Faction.OfInsects, canKidnap: true, canTimeoutOrFlee: false), map, list);
                 }
             }
         }
     }
 }