public static void postfix(SustainerManager __instance) { Blocker.Unblock(SustainerManagerPatch.listMutex); }
public static bool prefix(SustainerManager __instance) { Blocker.Block(SustainerManagerPatch.listMutex); return(true); }
public static bool UpdateAllSustainerScopes(SustainerManager __instance) { Dictionary <SoundDef, List <Sustainer> > playingPerDef = new Dictionary <SoundDef, List <Sustainer> >(); foreach (var kv in allSustainersDict) { Sustainer allSustainer = kv.Value; if (!playingPerDef.ContainsKey(allSustainer.def)) { if (!sListStack.TryPop(out List <Sustainer> sustainerList)) { sustainerList = new List <Sustainer>(); } sustainerList.Add(allSustainer); playingPerDef.Add(allSustainer.def, sustainerList); } else { playingPerDef[allSustainer.def].Add(allSustainer); } } foreach (KeyValuePair <SoundDef, List <Sustainer> > keyValuePair in playingPerDef) { SoundDef key = keyValuePair.Key; List <Sustainer> sustainerList = keyValuePair.Value; if (sustainerList.Count - key.maxVoices < 0) { for (int index = 0; index < sustainerList.Count; ++index) { sustainerList[index].scopeFader.inScope = true; } } else { for (int index = 0; index < sustainerList.Count; ++index) { sustainerList[index].scopeFader.inScope = false; } sustainerList.Sort((a, b) => a.CameraDistanceSquared.CompareTo(b.CameraDistanceSquared)); int num = 0; for (int index = 0; index < sustainerList.Count; ++index) { sustainerList[index].scopeFader.inScope = true; ++num; if (num >= key.maxVoices) { break; } } for (int index = 0; index < sustainerList.Count; ++index) { if (!sustainerList[index].scopeFader.inScope) { sustainerList[index].scopeFader.inScopePercent = 0.0f; } } } } foreach (KeyValuePair <SoundDef, List <Sustainer> > keyValuePair in playingPerDef) { keyValuePair.Value.Clear(); //SimplePool<List<Sustainer>>.Return(keyValuePair.Value); sListStack.Push(keyValuePair.Value); } //playingPerDef().Clear(); return(false); }
public static bool UpdateAllSustainerScopes(SustainerManager __instance) { //playingPerDef.Clear(); Dictionary <SoundDef, List <Sustainer> > playingPerDef = new Dictionary <SoundDef, List <Sustainer> >(); Sustainer sust; for (int index = 0; index < __instance.AllSustainers.Count; index++) { try { sust = __instance.AllSustainers[index]; } catch (ArgumentOutOfRangeException) { break; } if (null == sust) { continue; } if (!playingPerDef.ContainsKey(sust.def)) { List <Sustainer> list = new List <Sustainer>(); list.Add(sust); playingPerDef.Add(sust.def, list); } else { playingPerDef[sust.def].Add(sust); } } 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; } } else { 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(); return(false); }
public static bool DeregisterSustainer(SustainerManager __instance, Sustainer oldSustainer) { allSustainersDict.TryRemove(oldSustainer, out _); return(false); }
public static bool RegisterSustainer(SustainerManager __instance, Sustainer newSustainer) { allSustainersDict.TryAdd(newSustainer, newSustainer); return(false); }
public static bool get_AllSustainers(SustainerManager __instance, ref List <Sustainer> __result) { __result = allSustainersDict.Values.ToList(); return(false); }
public static bool UpdateAllSustainerScopes(SustainerManager __instance) { playingPerDef.Clear(); //replaced playingPerDef ThreadStatics List <Sustainer> snapshotSustainers = __instance.allSustainers; for (int index = 0; index < snapshotSustainers.Count; ++index) { Sustainer allSustainer = snapshotSustainers[index]; if (!playingPerDef.ContainsKey(allSustainer.def)) { List <Sustainer> sustainerList = SimplePool_Patch <List <Sustainer> > .Get(); sustainerList.Add(allSustainer); playingPerDef.Add(allSustainer.def, sustainerList); } else { playingPerDef[allSustainer.def].Add(allSustainer); } } foreach (KeyValuePair <SoundDef, List <Sustainer> > keyValuePair in playingPerDef) { SoundDef key = keyValuePair.Key; List <Sustainer> sustainerList = keyValuePair.Value; if (sustainerList.Count - key.maxVoices < 0) { for (int index = 0; index < sustainerList.Count; ++index) { sustainerList[index].scopeFader.inScope = true; } } else { for (int index = 0; index < sustainerList.Count; ++index) { sustainerList[index].scopeFader.inScope = false; } sustainerList.Sort(SustainerManager.SortSustainersByCameraDistanceCached); int num = 0; for (int index = 0; index < sustainerList.Count; ++index) { sustainerList[index].scopeFader.inScope = true; ++num; if (num >= key.maxVoices) { break; } } for (int index = 0; index < sustainerList.Count; ++index) { if (!sustainerList[index].scopeFader.inScope) { sustainerList[index].scopeFader.inScopePercent = 0.0f; } } } } foreach (KeyValuePair <SoundDef, List <Sustainer> > keyValuePair in playingPerDef) { keyValuePair.Value.Clear(); SimplePool_Patch <List <Sustainer> > .Return(keyValuePair.Value); } //playingPerDef.Clear(); return(false); }
public SoundRoot() { sourcePool = new AudioSourcePool(); sustainerManager = new SustainerManager(); oneShotManager = new SampleOneShotManager(); }