public virtual void StartMusic(TuneDef parmDef = null) { if (state == State.off) { state = State.on; } //Establish duration //Cthulhu.Utility.DebugReport("Cur Time:" + Time.time.ToString()); duration = Time.time + currentTuneDef.durationTime; //Cthulhu.Utility.DebugReport(currentTuneDef.ToString() + " Fin Time:" + duration.ToString()); //Clear old song this.playingSong = null; //Put on new song SoundInfo soundInfo = SoundInfo.InMap(this, MaintenanceType.None); SoundDef soundDef = currentTuneDef as SoundDef; if (parmDef != null) { soundDef = parmDef as SoundDef; } this.playingSong = SoundStarter.TrySpawnSustainer(soundDef, soundInfo); }
private void StartWickSustainer() { SoundDefOf.MetalHitImportant.PlayOneShot(parent); var info = SoundInfo.InMap(parent, MaintenanceType.PerTick); wickSoundSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(info); }
public void DraggerUpdate() { if (!dragging) { return; } List <IntVec3> list = DragCells; SelDes.RenderHighlight(list); if (list.Count != lastFrameDragCellsDrawn) { lastDragRealTime = Time.realtimeSinceStartup; lastFrameDragCellsDrawn = list.Count; if (SelDes.soundDragChanged != null) { SelDes.soundDragChanged.PlayOneShotOnCamera(); } } if (sustainer == null || sustainer.Ended) { if (SelDes.soundDragSustain != null) { sustainer = SelDes.soundDragSustain.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame)); } } else { sustainer.externalParams["TimeSinceDrag"] = Time.realtimeSinceStartup - lastDragRealTime; sustainer.Maintain(); } }
protected void MeditationTick() { pawn.skills.Learn(SkillDefOf.Intellectual, 0.0180000011f); pawn.GainComfortFromCellIfPossible(); if (pawn.needs.joy != null) { JoyUtility.JoyTickCheckEnd(pawn, JoyTickFullJoyAction.None); } if (pawn.IsHashIntervalTick(100)) { MoteMaker.ThrowMetaIcon(pawn.Position, pawn.Map, ThingDefOf.Mote_Meditating); } if (!ModsConfig.RoyaltyActive) { return; } pawn.psychicEntropy.Notify_Meditated(); if (pawn.HasPsylink && pawn.psychicEntropy.PsychicSensitivity > float.Epsilon) { if (psyfocusMote == null || psyfocusMote.Destroyed) { psyfocusMote = MoteMaker.MakeAttachedOverlay(pawn, ThingDefOf.Mote_PsyfocusPulse, Vector3.zero); } psyfocusMote.Maintain(); if (sustainer == null || sustainer.Ended) { sustainer = SoundDefOf.MeditationGainPsyfocus.TrySpawnSustainer(SoundInfo.InMap(pawn, MaintenanceType.PerTick)); } sustainer.Maintain(); pawn.psychicEntropy.GainPsyfocus(Focus.Thing); } }
private void FinalizeEffecter() { this.effecter?.Cleanup(); this.sound?.End(); this.effecter = null; this.sound = null; }
private void <CreateSustainer> m__0() { SoundDef tornado = SoundDefOf.Tornado; this.sustainer = tornado.TrySpawnSustainer(SoundInfo.InMap(this, MaintenanceType.PerTick)); this.UpdateSustainerVolume(); }
public void WeatherManagerTick() { this.eventHandler.WeatherEventHandlerTick(); this.curWeatherAge++; this.curWeather.Worker.WeatherTick(this.map, this.TransitionLerpFactor); this.lastWeather.Worker.WeatherTick(this.map, 1f - this.TransitionLerpFactor); this.growthSeasonMemory.GrowthSeasonMemoryTick(); for (int i = 0; i < this.curWeather.ambientSounds.Count; i++) { bool flag = false; for (int j = this.ambienceSustainers.Count - 1; j >= 0; j--) { if (this.ambienceSustainers[j].def == this.curWeather.ambientSounds[i]) { flag = true; break; } } if (!flag && this.VolumeOfAmbientSound(this.curWeather.ambientSounds[i]) > 0.0001f) { SoundInfo info = SoundInfo.OnCamera(MaintenanceType.None); Sustainer sustainer = this.curWeather.ambientSounds[i].TrySpawnSustainer(info); if (sustainer != null) { this.ambienceSustainers.Add(sustainer); } } } }
protected void StartWick() { JState = JetterState.WickBurning; WickTicksLeft = 25; SoundDefOf.MetalHitImportant.PlayOneShot(this); wickSoundSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(this); }
private void StartSpray() { SnowUtility.AddSnowRadial(this.OccupiedRect().RandomCell, Map, 4, -0.06f); spraySustainer = SoundStarter.TrySpawnSustainer(SoundDefOf.GeyserSpray, new TargetInfo(Position, Map)); spraySustainerStartTick = Find.TickManager.TicksGame; }
public static Toil PlaySustainerOrSound(this Toil toil, Func <SoundDef> soundDefGetter) { Sustainer sustainer = null; toil.AddPreInitAction(delegate { SoundDef soundDef2 = soundDefGetter(); if (soundDef2 != null && !soundDef2.sustain) { soundDef2.PlayOneShot(new TargetInfo(toil.GetActor().Position, toil.GetActor().Map)); } }); toil.AddPreTickAction(delegate { if (sustainer == null || sustainer.Ended) { SoundDef soundDef = soundDefGetter(); if (soundDef != null && soundDef.sustain) { SoundInfo info = SoundInfo.InMap(toil.actor, MaintenanceType.PerTick); sustainer = soundDef.TrySpawnSustainer(info); } } else { sustainer.Maintain(); } }); return(toil); }
private void StartWickSustainer() { SoundDefOf.MetalHitImportant.PlayOneShot(new TargetInfo(parent.Position, parent.Map)); SoundInfo info = SoundInfo.InMap(parent, MaintenanceType.PerTick); wickSoundSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(info); }
public Stance_Warmup(int ticks, LocalTargetInfo focusTarg, Verb verb) : base(ticks, focusTarg, verb) { if (focusTarg.HasThing && focusTarg.Thing is Pawn) { Pawn pawn = (Pawn)focusTarg.Thing; targetStartedDowned = pawn.Downed; if (pawn.apparel != null) { for (int i = 0; i < pawn.apparel.WornApparelCount; i++) { (pawn.apparel.WornApparel[i] as ShieldBelt)?.KeepDisplaying(); } } } if (verb != null) { if (verb.verbProps.soundAiming != null) { SoundInfo info = SoundInfo.InMap(verb.caster, MaintenanceType.PerTick); if (verb.CasterIsPawn) { info.pitchFactor = 1f / verb.CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor); } sustainer = verb.verbProps.soundAiming.TrySpawnSustainer(info); } if (verb.verbProps.warmupEffecter != null && verb.Caster != null) { effecter = verb.verbProps.warmupEffecter.Spawn(verb.Caster, verb.Caster.Map); effecter.Trigger(verb.Caster, focusTarg.ToTargetInfo(verb.Caster.Map)); } } drawAimPie = verb?.verbProps.drawAimPie ?? false; }
private static void RecreateMapSustainers() { if (!AmbientSoundManager.AltitudeWindSoundCreated) { SoundDefOf.Ambient_AltitudeWind.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.None)); } SustainerManager sustainerManager = Find.SoundRoot.sustainerManager; for (int i = 0; i < AmbientSoundManager.biomeAmbientSustainers.Count; i++) { Sustainer sustainer = AmbientSoundManager.biomeAmbientSustainers[i]; if (sustainerManager.AllSustainers.Contains(sustainer) && !sustainer.Ended) { sustainer.End(); } } AmbientSoundManager.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(MaintenanceType.None)); AmbientSoundManager.biomeAmbientSustainers.Add(item); } } }
public void DraggerUpdate() { if (this.dragging) { List <IntVec3> list = this.DragCells; for (int i = 0; i < list.Count; i++) { Graphics.DrawMesh(MeshPool.plane10, list[i].ToVector3Shifted() + 10f * Vector3.up, Quaternion.identity, DesignationDragger.DragHighlightCellMat, 0); } if (list.Count != this.lastFrameDragCellsDrawn) { this.lastDragRealTime = Time.realtimeSinceStartup; this.lastFrameDragCellsDrawn = list.Count; if (this.SelDes.soundDragChanged != null) { this.SelDes.soundDragChanged.PlayOneShotOnCamera(null); } } if (this.sustainer == null || this.sustainer.Ended) { if (this.SelDes.soundDragSustain != null) { this.sustainer = this.SelDes.soundDragSustain.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame)); } } else { this.sustainer.externalParams["TimeSinceDrag"] = Time.realtimeSinceStartup - this.lastDragRealTime; this.sustainer.Maintain(); } } }
public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing equipment = null, Thing intendedTarget = null) { this.launcher = launcher; this.origin = origin; this.intendedTarget = intendedTarget; if (equipment != null) { this.equipmentDef = equipment.def; } else { this.equipmentDef = null; } if (targ.Thing != null) { this.assignedTarget = targ.Thing; } 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.InMap(this, MaintenanceType.PerTick); this.ambientSustainer = this.def.projectile.soundAmbient.TrySpawnSustainer(info); } }
public void DraggerUpdate() { if (this.dragging) { List <IntVec3> list = this.DragCells; this.SelDes.RenderHighlight(list); if (list.Count != this.lastFrameDragCellsDrawn) { this.lastDragRealTime = Time.realtimeSinceStartup; this.lastFrameDragCellsDrawn = list.Count; if (this.SelDes.soundDragChanged != null) { this.SelDes.soundDragChanged.PlayOneShotOnCamera(null); } } if (this.sustainer == null || this.sustainer.Ended) { if (this.SelDes.soundDragSustain != null) { this.sustainer = this.SelDes.soundDragSustain.TrySpawnSustainer(SoundInfo.OnCamera(MaintenanceType.PerFrame)); } } else { this.sustainer.externalParams["TimeSinceDrag"] = Time.realtimeSinceStartup - this.lastDragRealTime; this.sustainer.Maintain(); } } }
public Stance_Warmup(int ticks, LocalTargetInfo focusTarg, Verb verb) : base(ticks, focusTarg, verb) { if (focusTarg.HasThing && focusTarg.Thing is Pawn) { Pawn pawn = (Pawn)focusTarg.Thing; this.targetStartedDowned = pawn.Downed; if (pawn.apparel != null) { for (int i = 0; i < pawn.apparel.WornApparelCount; i++) { Apparel apparel = pawn.apparel.WornApparel[i]; ShieldBelt shieldBelt = apparel as ShieldBelt; if (shieldBelt != null) { shieldBelt.KeepDisplaying(); } } } } if (verb != null && verb.verbProps.soundAiming != null) { SoundInfo info = SoundInfo.InMap(verb.caster, MaintenanceType.PerTick); if (verb.CasterIsPawn) { info.pitchFactor = (float)(1.0 / verb.CasterPawn.GetStatValue(StatDefOf.AimingDelayFactor, true)); } this.sustainer = verb.verbProps.soundAiming.TrySpawnSustainer(info); } }
public static Sustainer AggregateOrSpawnSustainerFor(ISizeReporter reporter, SoundDef def, SoundInfo info) { Sustainer sustainer = null; foreach (Sustainer allSustainer in Find.SoundRoot.sustainerManager.AllSustainers) { if (allSustainer.def == def && allSustainer.info.Maker.Map == info.Maker.Map && allSustainer.info.Maker.Cell.InHorDistOf(info.Maker.Cell, AggregateRadius)) { sustainer = allSustainer; break; } } if (sustainer == null) { sustainer = def.TrySpawnSustainer(info); } else { sustainer.Maintain(); } if (sustainer.externalParams.sizeAggregator == null) { sustainer.externalParams.sizeAggregator = new SoundSizeAggregator(); } sustainer.externalParams.sizeAggregator.RegisterReporter(reporter); return(sustainer); }
private void StartRotationSound() { StopRotationSound(); SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.None); this.rotationSoundSustainer = this.def.building.soundDispense.TrySpawnSustainer(info); }
public void WeatherManagerTick() { this.eventHandler.WeatherEventHandlerTick(); this.curWeatherAge++; this.curWeather.Worker.WeatherTick(this.map, this.TransitionLerpFactor); this.lastWeather.Worker.WeatherTick(this.map, (float)(1.0 - this.TransitionLerpFactor)); this.growthSeasonMemory.GrowthSeasonMemoryTick(); for (int i = 0; i < this.curWeather.ambientSounds.Count; i++) { bool flag = false; int num = this.ambienceSustainers.Count - 1; while (num >= 0) { if (this.ambienceSustainers[num].def != this.curWeather.ambientSounds[i]) { num--; continue; } flag = true; break; } if (!flag && this.VolumeOfAmbientSound(this.curWeather.ambientSounds[i]) > 9.9999997473787516E-05) { SoundInfo info = SoundInfo.OnCamera(MaintenanceType.None); Sustainer sustainer = this.curWeather.ambientSounds[i].TrySpawnSustainer(info); if (sustainer != null) { this.ambienceSustainers.Add(sustainer); } } } }
void StartSustainer() { if (HasSkiddingSound) { skiddingSustainer = SkiddingSustainSound.TrySpawnSustainer(new TargetInfo(Position, Map)); } }
public void WeatherManagerTick() { eventHandler.WeatherEventHandlerTick(); curWeatherAge++; curWeather.Worker.WeatherTick(map, TransitionLerpFactor); lastWeather.Worker.WeatherTick(map, 1f - TransitionLerpFactor); growthSeasonMemory.GrowthSeasonMemoryTick(); for (int i = 0; i < curWeather.ambientSounds.Count; i++) { bool flag = false; for (int num = ambienceSustainers.Count - 1; num >= 0; num--) { if (ambienceSustainers[num].def == curWeather.ambientSounds[i]) { flag = true; break; } } if (!flag && VolumeOfAmbientSound(curWeather.ambientSounds[i]) > 0.0001f) { SoundInfo info = SoundInfo.OnCamera(); Sustainer sustainer = curWeather.ambientSounds[i].TrySpawnSustainer(info); if (sustainer != null) { ambienceSustainers.Add(sustainer); } } } }
public static bool AggregateOrSpawnSustainerFor(ref Sustainer __result, ISizeReporter reporter, SoundDef def, SoundInfo info) { Sustainer sustainer = null; Sustainer allSustainer; for (int i = 0; i < Find.SoundRoot.sustainerManager.AllSustainers.Count; i++) { try { allSustainer = Find.SoundRoot.sustainerManager.AllSustainers[i]; } catch (ArgumentOutOfRangeException) { break; } if (allSustainer != null && allSustainer.def == def && allSustainer.info.Maker.Map == info.Maker.Map && allSustainer.info.Maker.Cell.InHorDistOf(info.Maker.Cell, AggregateRadius)) { sustainer = allSustainer; break; } } if (sustainer == null) { sustainer = def.TrySpawnSustainer(info); } else { sustainer.Maintain(); } if (sustainer.externalParams.sizeAggregator == null) { sustainer.externalParams.sizeAggregator = new SoundSizeAggregator(); } sustainer.externalParams.sizeAggregator.RegisterReporter(reporter); __result = sustainer; return false; }
//Added new calculations for downed pawns, destination public virtual void Launch(Thing launcher, Vector3 origin, LocalTargetInfo targ, Thing equipment = null) { if (shotSpeed < 0) { shotSpeed = def.projectile.speed; } this.launcher = launcher; this.origin = origin; if (equipment != null) { equipmentDef = equipment.def; } else { equipmentDef = null; } //Checking if target was downed on launch if (targ.Thing != null) { assignedTarget = targ.Thing; } //Checking if a new destination was set if (destination == null) { destination = targ.Cell.ToVector3Shifted() + new Vector3(Rand.Range(-0.3f, 0.3f), 0f, Rand.Range(-0.3f, 0.3f)); } ticksToImpact = StartingTicksToImpact; if (!def.projectile.soundAmbient.NullOrUndefined()) { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick); ambientSustainer = def.projectile.soundAmbient.TrySpawnSustainer(info); } }
protected override void Impact(Thing hitThing) { if (!this.initialized) { Initialize(); this.initialized = true; } if (this.sustainer != null) { this.sustainer.info.volumeFactor = 2f; this.sustainer.Maintain(); if (this.TicksLeft <= 0) { this.sustainer.End(); this.sustainer = null; } } if (this.sfBeams != null && this.sfBeams.Count > 0) { DoSunfireActions(); } if (sfBeams == null || sfBeams.Count <= 0 || this.ignoreAge) { this.ignoreAge = true; Destroy(DestroyMode.Vanish); } if (!this.ignoreAge) { Destroy(DestroyMode.Vanish); } }
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); }
/// <summary> /// Create percussion sounds for the detected meter /// </summary> /// <param name="midi"></param> /// <param name="prolongSustainedNotes"></param> /// <param name="volume"></param> public static void AddBeats(Model midi, bool prolongSustainedNotes = false, int volume = 127) { var channel = midi.Tracks[0].Channels[Channel.PercussionChannelNumber]; var beatEvents = midi.EventsOfType <BeatEvent>().OrderBy(b => b.AbsoluteRealTime); foreach (var beat in beatEvents) { var length = TimeSpan.FromMilliseconds(beat.Length.TotalMilliseconds * 0.25); var note = new NoteOn { ChannelNumber = Channel.PercussionChannelNumber, NoteNumber = beat.Level == 0 ? (byte)36 : (byte)44, Volume = beat.Level == 2 ? (byte)(0.75 * volume) : (byte)volume, AbsoluteRealTime = beat.AbsoluteRealTime, AbsoluteTime = beat.AbsoluteTime, RealTimeLength = length, End = beat.AbsoluteRealTime + length }; channel.Events.Add(note); } var collector = new VolumeChangeCollector(midi); collector.DetermineVolumes(); if (prolongSustainedNotes) { var sustainer = new Sustainer(midi); sustainer.ProlongSustainedNotes(); } }
// ===================== Sound ===================== public void StartRotationSound() { StopRotationSound(); SoundInfo info = SoundInfo.InMap(this, MaintenanceType.None); this.rotationSoundSustainer = SoundDef.Named("GeothermalPlant_Ambience").TrySpawnSustainer(info); }
public void Launch(Thing launcher, Vector3 origin, LocalTargetInfo usedTarget, LocalTargetInfo intendedTarget, ProjectileHitFlags hitFlags, Thing equipment = null, ThingDef targetCoverDef = null) { this.launcher = launcher; this.origin = origin; this.usedTarget = usedTarget; this.intendedTarget = intendedTarget; this.targetCoverDef = targetCoverDef; this.HitFlags = hitFlags; if (equipment != null) { this.equipmentDef = equipment.def; this.weaponDamageMultiplier = equipment.GetStatValue(StatDefOf.RangedWeapon_DamageMultiplier, true); } else { this.equipmentDef = null; this.weaponDamageMultiplier = 1f; } this.destination = usedTarget.Cell.ToVector3Shifted() + Gen.RandomHorizontalVector(0.3f); this.ticksToImpact = this.StartingTicksToImpact; if (!this.def.projectile.soundAmbient.NullOrUndefined()) { SoundInfo info = SoundInfo.InMap(this, MaintenanceType.PerTick); this.ambientSustainer = this.def.projectile.soundAmbient.TrySpawnSustainer(info); } }
protected void StartWick() { this.JState = Jetter.JetterState.WickBurning; this.WickTicksLeft = 25; SoundDef.Named("MetalHitImportant").PlayOneShot(this); this.wickSoundSustainer = SoundDef.Named("HissSmall").TrySpawnSustainer(this); }
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); }
private void StartSustainerPressurizedIfInactive() { if (base.props.soundAmbientPowered.NullOrUndefined() && (this.sustainerPressurized == null)) { SoundInfo info = SoundInfo.InWorld(base.parent, MaintenanceType.None); this.sustainerPressurized = base.props.soundAmbientPowered.TrySpawnSustainer(info); } }
public void StartWickSustainer() { SoundInfo info = SoundInfo.InWorld(this, MaintenanceType.PerTick); this.wickSustainer = SoundDefOf.HissSmall.TrySpawnSustainer(info); }
public override void ResetGasVars() { base.ResetGasVars(); this.heatQtyOutputInt = 0f; this.heatLastOutputted = false; this.wantTransfer = true; this.sustainerPressurized = null; }
private void EndSustainerPressurizedIfActive() { if (this.sustainerPressurized != null) { this.sustainerPressurized.End(); this.sustainerPressurized = null; } }
private void StopRotationSound() { if (this.rotationSoundSustainer != null) { this.rotationSoundSustainer.End(); this.rotationSoundSustainer = null; } }
//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); } }