internal static void RenderEveryTick(LoopingSoundManager instance, float dt) { _ = instance; _ = dt; // Dummy code to ensure no inlining while (System.DateTime.Now.Ticks > 0L) { throw new NotImplementedException("Reverse patch stub"); } }
public void UpdateVelocity(string asset, Vector2 value) { foreach (LoopingSoundEvent loopingSound in loopingSounds) { LoopingSoundEvent current = loopingSound; if (current.asset == asset) { LoopingSoundManager.Get().UpdateVelocity(current.handle, value); break; } } }
public void SetParameter(string path, HashedString parameter, float value) { foreach (LoopingSoundEvent loopingSound in loopingSounds) { LoopingSoundEvent current = loopingSound; if (current.asset == path) { LoopingSoundManager.Get().UpdateFirstParameter(current.handle, parameter, value); break; } } }
public void UpdateSecondParameter(string asset, HashedString parameter, float value) { foreach (LoopingSoundEvent loopingSound in loopingSounds) { LoopingSoundEvent current = loopingSound; if (current.asset == asset) { LoopingSoundManager.Get().UpdateSecondParameter(current.handle, parameter, value); break; } } }
public bool StartSound(string asset, bool pause_on_game_pause = true, bool enable_culling = true, bool enable_camera_scaled_position = true) { if (asset == null || asset == string.Empty) { Debug.LogWarning("Missing sound"); return(false); } if (!IsSoundPlaying(asset)) { LoopingSoundEvent loopingSoundEvent = default(LoopingSoundEvent); loopingSoundEvent.asset = asset; LoopingSoundEvent item = loopingSoundEvent; item.handle = LoopingSoundManager.Get().Add(asset, base.transform.GetPosition(), base.transform, pause_on_game_pause, enable_culling, enable_camera_scaled_position); loopingSounds.Add(item); } return(true); }
public bool StartSound(string asset) { if (asset == null || asset == string.Empty) { Debug.LogWarning("Missing sound"); return(false); } if (!IsSoundPlaying(asset)) { LoopingSoundEvent loopingSoundEvent = default(LoopingSoundEvent); loopingSoundEvent.asset = asset; LoopingSoundEvent item = loopingSoundEvent; item.handle = LoopingSoundManager.Get().Add(asset, base.transform.GetPosition(), base.transform, true, true, true); loopingSounds.Add(item); } return(true); }
public bool StartSound(string asset, AnimEventManager.EventPlayerData behaviour, EffectorValues noiseValues, bool ignore_pause = false, bool enable_camera_scaled_position = true) { if (asset == null || asset == string.Empty) { Debug.LogWarning("Missing sound"); return(false); } if (!IsSoundPlaying(asset)) { LoopingSoundEvent loopingSoundEvent = default(LoopingSoundEvent); loopingSoundEvent.asset = asset; LoopingSoundEvent item = loopingSoundEvent; Vector3 position = behaviour.GetComponent <Transform>().GetPosition(); item.handle = LoopingSoundManager.Get().Add(asset, position, base.transform, !ignore_pause, true, enable_camera_scaled_position); loopingSounds.Add(item); } return(true); }
private void UpdateSounds(float t) { clearList.Clear(); foreach (KeyValuePair <int, SoundInfo> topSound in topSounds) { SoundInfo value = topSound.Value; float num = t - value.startTime; if (num >= stopTopLoopDelay) { if (value.handle != HandleVector <int> .InvalidHandle) { LoopingSoundManager.StopSound(value.handle); } clearList.Add(topSound.Key); } } foreach (int clear in clearList) { topSounds.Remove(clear); } clearList.Clear(); foreach (KeyValuePair <int, SoundInfo> splashSound in splashSounds) { SoundInfo value2 = splashSound.Value; float num2 = t - value2.startTime; if (num2 >= stopSplashLoopDelay) { if (value2.handle != HandleVector <int> .InvalidHandle) { LoopingSoundManager.StopSound(value2.handle); } clearList.Add(splashSound.Key); } } foreach (int clear2 in clearList) { splashSounds.Remove(clear2); } clearList.Clear(); }
public void Render200ms(float dt) { if (KPlayerPrefs.GetFloat(VOLUME_MASTER, 1.0f) > 0.0f && !FastTrackOptions. Instance.DisableSound) { #if false var lsm = LoopingSoundManager.Get(); if (lsm != null) { LoopingSoundManagerUpdater.RenderEveryTick(lsm, dt); } #endif if (KPlayerPrefs.GetFloat(VOLUME_AMBIENCE, 1.0f) > 0.0f) { StartCoroutine(RunAmbienceNextFrame()); runMix = true; } else { runMix = false; } } }
private void AddToSim(int cell, int particleIdx, ref int num_particles) { bool flag = false; do { Element element = Grid.Element[cell]; Element.State state = element.state & Element.State.Solid; if (state == Element.State.Solid || (Grid.Properties[cell] & 2) != 0) { cell += Grid.WidthInCells; if (!Grid.IsValidCell(cell)) { return; } } else { flag = true; } }while (!flag); ParticleProperties particleProperties = this.particleProperties[particleIdx]; SimMessages.AddRemoveSubstance(cell, particleProperties.elementIdx, CellEventLogger.Instance.FallingWaterAddToSim, particleProperties.mass, particleProperties.temperature, particleProperties.diseaseIdx, particleProperties.diseaseCount, true, -1); RemoveParticle(particleIdx, ref num_particles); float time = GetTime(); float num = lastSpawnTime[cell]; if (time - num >= minSpawnDelay) { lastSpawnTime[cell] = time; Vector3 vector = Grid.CellToPosCCC(cell, Grid.SceneLayer.TileMain); if (CameraController.Instance.IsAudibleSound(vector)) { bool flag2 = true; if (splashSounds.TryGetValue(cell, out SoundInfo value)) { value.splashCount++; if (value.splashCount > splashCountLoopThreshold) { if (value.handle == HandleVector <int> .InvalidHandle) { value.handle = LoopingSoundManager.StartSound(liquid_splash_loop, vector, true, true); } LoopingSoundManager.Get().UpdateFirstParameter(value.handle, HASH_LIQUIDDEPTH, SoundUtil.GetLiquidDepth(cell)); LoopingSoundManager.Get().UpdateSecondParameter(value.handle, HASH_LIQUIDVOLUME, GetParticleVolume(particleProperties.mass)); flag2 = false; } } else { value = default(SoundInfo); value.handle = HandleVector <int> .InvalidHandle; } value.startTime = time; splashSounds[cell] = value; if (flag2) { EventInstance instance = SoundEvent.BeginOneShot(liquid_splash_initial, vector); instance.setParameterValue("liquidDepth", SoundUtil.GetLiquidDepth(cell)); instance.setParameterValue("liquidVolume", GetParticleVolume(particleProperties.mass)); SoundEvent.EndOneShot(instance); } } } }
public void AddParticle(Vector2 root_pos, byte elementIdx, float base_mass, float temperature, byte disease_idx, int base_disease_count, bool skip_sound = false, bool skip_decor = false, bool debug_track = false, bool disable_randomness = false) { int num = Grid.PosToCell(root_pos); if (!Grid.IsValidCell(num)) { KCrashReporter.Assert(false, "Trying to add falling water outside of the scene"); } else { if (temperature <= 0f || base_mass <= 0f) { Debug.LogError($"Unexpected water mass/temperature values added to the falling water manager T({temperature}) M({base_mass})"); } float time = GetTime(); if (!skip_sound) { if (!topSounds.TryGetValue(num, out SoundInfo value)) { value = default(SoundInfo); value.handle = LoopingSoundManager.StartSound(liquid_top_loop, root_pos, true, true); } value.startTime = time; LoopingSoundManager.Get().UpdateSecondParameter(value.handle, HASH_LIQUIDVOLUME, SoundUtil.GetLiquidVolume(base_mass)); topSounds[num] = value; } while (base_mass > 0f) { float num2 = UnityEngine.Random.value * 2f * particleMassVariation - particleMassVariation; float num3 = Mathf.Max(0f, Mathf.Min(base_mass, particleMassToSplit + num2)); float num4 = num3 / base_mass; base_mass -= num3; int disease_count = (int)(num4 * (float)base_disease_count); int frame = UnityEngine.Random.Range(0, numFrames); Vector2 b = (!disable_randomness) ? new Vector2(jitterStep * Mathf.Sin(offset), jitterStep * Mathf.Sin(offset + 17f)) : Vector2.zero; Vector2 b2 = (!disable_randomness) ? new Vector2(UnityEngine.Random.Range(0f - multipleOffsetRange.x, multipleOffsetRange.x), UnityEngine.Random.Range(0f - multipleOffsetRange.y, multipleOffsetRange.y)) : Vector2.zero; Element element = ElementLoader.elements[elementIdx]; Vector2 vector = root_pos; bool flag = !skip_decor && SpawnLiquidTopDecor(time, Grid.CellLeft(num), false, element); bool flag2 = !skip_decor && SpawnLiquidTopDecor(time, Grid.CellRight(num), true, element); Vector2 b3 = Vector2.ClampMagnitude(initialOffset + b + b2, 1f); if (flag || flag2) { if (flag && flag2) { vector += b3; vector.x += 0.5f; } else if (flag) { vector += b3; } else { vector.x += 1f - b3.x; vector.y += b3.y; } } else { vector += b3; vector.x += 0.5f; } int num5 = Grid.PosToCell(vector); Element element2 = Grid.Element[num5]; Element.State state = element2.state & Element.State.Solid; if (state == Element.State.Solid || (Grid.Properties[num5] & 2) != 0) { vector.y = Mathf.Floor(vector.y + 1f); } physics.Add(new ParticlePhysics(vector, Vector2.zero, frame, elementIdx)); particleProperties.Add(new ParticleProperties(elementIdx, num3, temperature, disease_idx, disease_count, debug_track)); } } }
private void StopSoundAtIndex(int i) { LoopingSoundEvent loopingSoundEvent = loopingSounds[i]; LoopingSoundManager.StopSound(loopingSoundEvent.handle); }
protected override void OnPrefabInit() { instance = this; CollectParameterUpdaters(); }
public static void DestroyInstance() { instance = null; }