public static Sustainer AggregateOrSpawnSustainerFor(ISizeReporter reporter, SoundDef def, SoundInfo info) { Sustainer sustainer = null; foreach (Sustainer sustainer2 in Find.SoundRoot.sustainerManager.AllSustainers) { if (sustainer2.def == def && sustainer2.info.Maker.Map == info.Maker.Map && sustainer2.info.Maker.Cell.InHorDistOf(info.Maker.Cell, SustainerAggregatorUtility.AggregateRadius)) { sustainer = sustainer2; 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); }
public void UpdateAllSustainerScopes() { playingPerDef.Clear(); for (int i = 0; i < allSustainers.Count; i++) { Sustainer sustainer = allSustainers[i]; if (!playingPerDef.ContainsKey(sustainer.def)) { List <Sustainer> list = SimplePool <List <Sustainer> > .Get(); list.Add(sustainer); playingPerDef.Add(sustainer.def, list); } else { playingPerDef[sustainer.def].Add(sustainer); } } foreach (KeyValuePair <SoundDef, List <Sustainer> > item in playingPerDef) { SoundDef key = item.Key; List <Sustainer> value = item.Value; if (value.Count - key.maxVoices < 0) { for (int j = 0; j < value.Count; j++) { value[j].scopeFader.inScope = true; } continue; } for (int k = 0; k < value.Count; k++) { value[k].scopeFader.inScope = false; } value.Sort(SortSustainersByCameraDistanceCached); int num = 0; for (int l = 0; l < value.Count; l++) { value[l].scopeFader.inScope = true; num++; if (num >= key.maxVoices) { break; } } for (int m = 0; m < value.Count; m++) { if (!value[m].scopeFader.inScope) { value[m].scopeFader.inScopePercent = 0f; } } } foreach (KeyValuePair <SoundDef, List <Sustainer> > item2 in playingPerDef) { item2.Value.Clear(); SimplePool <List <Sustainer> > .Return(item2.Value); } playingPerDef.Clear(); }
static bool Prefix(Verse.Sound.Sustainer __instance) { if (__instance.def == WTH_DefOf.WTH_Sound_Overdrive && __instance.Ended) { return(false); } return(true); }
public static Sustainer TrySpawnSustainer(this SoundDef soundDef, SoundInfo info) { DebugSoundEventsLog.Notify_SoundEvent(soundDef, info); Sustainer result; if (soundDef == null) { result = null; } else if (soundDef.isUndefined) { if (Prefs.DevMode && Find.WindowStack.IsOpen(typeof(EditWindow_DefEditor))) { DefDatabase <SoundDef> .Clear(); DefDatabase <SoundDef> .AddAllInMods(); SoundDef soundDef2 = SoundDef.Named(soundDef.defName); if (!soundDef2.isUndefined) { return(soundDef2.TrySpawnSustainer(info)); } } result = null; } else if (!soundDef.sustain) { Log.Error("Tried to spawn a sustainer from non-sustainer sound " + soundDef + ".", false); result = null; } else if (!info.IsOnCamera && info.Maker.Thing != null && info.Maker.Thing.Destroyed) { result = null; } else { if (soundDef.sustainStartSound != null) { soundDef.sustainStartSound.PlayOneShot(info); } result = new Sustainer(soundDef, info); } return(result); }
public SubSustainer(Sustainer parent, SubSoundDef subSoundDef) { this.parent = parent; this.subDef = subSoundDef; LongEventHandler.ExecuteWhenFinished(delegate { this.creationFrame = Time.frameCount; this.creationRealTime = Time.realtimeSinceStartup; if (Current.ProgramState == ProgramState.Playing) { this.creationTick = Find.TickManager.TicksGame; } if (this.subDef.startDelayRange.TrueMax < 0.001f) { this.StartSample(); } else { this.nextSampleStartTime = Time.realtimeSinceStartup + this.subDef.startDelayRange.RandomInRange; } }); }
public void DeregisterSustainer(Sustainer oldSustainer) { allSustainers.Remove(oldSustainer); }
public void RegisterSustainer(Sustainer newSustainer) { allSustainers.Add(newSustainer); }
public static void Notify_SustainerEnded(Sustainer sustainer, SoundInfo info) { string str = "SustainerEnd: " + sustainer.def.defName + " - " + info.ToString(); DebugSoundEventsLog.CreateRecord(str); }
public void UpdateAllSustainerScopes() { for (int i = 0; i < this.allSustainers.Count; i++) { Sustainer sustainer = this.allSustainers[i]; if (!SustainerManager.playingPerDef.ContainsKey(sustainer.def)) { List <Sustainer> list = SimplePool <List <Sustainer> > .Get(); list.Add(sustainer); SustainerManager.playingPerDef.Add(sustainer.def, list); } else { SustainerManager.playingPerDef[sustainer.def].Add(sustainer); } } foreach (KeyValuePair <SoundDef, List <Sustainer> > keyValuePair in SustainerManager.playingPerDef) { SoundDef key = keyValuePair.Key; List <Sustainer> value = keyValuePair.Value; int num = value.Count - key.maxVoices; if (num < 0) { for (int j = 0; j < value.Count; j++) { value[j].scopeFader.inScope = true; } } else { for (int k = 0; k < value.Count; k++) { value[k].scopeFader.inScope = false; } int num2 = 0; foreach (Sustainer sustainer2 in from lo in value orderby lo.CameraDistanceSquared select lo) { sustainer2.scopeFader.inScope = true; num2++; if (num2 >= key.maxVoices) { break; } } for (int l = 0; l < value.Count; l++) { if (!value[l].scopeFader.inScope) { value[l].scopeFader.inScopePercent = 0f; } } } } foreach (KeyValuePair <SoundDef, List <Sustainer> > keyValuePair2 in SustainerManager.playingPerDef) { keyValuePair2.Value.Clear(); SimplePool <List <Sustainer> > .Return(keyValuePair2.Value); } SustainerManager.playingPerDef.Clear(); }
private static float <UpdateAllSustainerScopes> m__0(Sustainer lo) { return(lo.CameraDistanceSquared); }
public static void Notify_SustainerEnded(Sustainer sustainer, SoundInfo info) { CreateRecord("SustainerEnd: " + sustainer.def.defName + " - " + info.ToString()); }