private void OnLanded(object data) { if (!((UnityEngine.Object)CameraController.Instance == (UnityEngine.Object)null)) { Vector3 position = base.transform.GetPosition(); Vector2I vector2I = Grid.PosToXY(position); if (vector2I.x < 0 || Grid.WidthInCells <= vector2I.x || vector2I.y < 0 || Grid.HeightInCells <= vector2I.y) { this.DeleteObject(); } else { Vector2 vector = (Vector2)data; float sqrMagnitude = vector.sqrMagnitude; if (!(sqrMagnitude <= 0.2f) && !SpeedControlScreen.Instance.IsPaused) { Element element = primaryElement.Element; if (element.substance != null) { string text = element.substance.GetOreBumpSound(); if (text == null) { text = (element.HasTag(GameTags.RefinedMetal) ? "RefinedMetal" : ((!element.HasTag(GameTags.Metal)) ? "Rock" : "RawMetal")); } text = ((!(element.tag.ToString() == "Creature") || base.gameObject.HasTag(GameTags.Seed)) ? ("Ore_bump_" + text) : "Bodyfall_rock"); string sound = GlobalAssets.GetSound(text, true); sound = ((sound == null) ? GlobalAssets.GetSound("Ore_bump_rock", false) : sound); if (CameraController.Instance.IsAudibleSound(base.transform.GetPosition(), sound)) { int num = Grid.PosToCell(position); bool isLiquid = Grid.Element[num].IsLiquid; float value = 0f; if (isLiquid) { value = SoundUtil.GetLiquidDepth(num); } FMOD.Studio.EventInstance instance = KFMOD.BeginOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(base.transform.GetPosition())); instance.setParameterValue("velocity", vector.magnitude); instance.setParameterValue("liquidDepth", value); KFMOD.EndOneShot(instance); } } } } } }
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 override void PlaySound(AnimEventManager.EventPlayerData behaviour) { Vector3 pos = behaviour.GetComponent <Transform>().GetPosition(); KBatchedAnimController component = behaviour.GetComponent <KBatchedAnimController>(); if ((Object)component != (Object)null) { pos = component.GetPivotSymbolPosition(); } int num = Grid.PosToCell(pos); int cell = Grid.CellBelow(num); string audioCategory = GetAudioCategory(cell); string name = StringFormatter.Combine(audioCategory, "_", base.name); string sound = GlobalAssets.GetSound(name, true); if (sound == null) { name = StringFormatter.Combine("Rock_", base.name); sound = GlobalAssets.GetSound(name, true); if (sound == null) { name = base.name; sound = GlobalAssets.GetSound(name, true); } } if (!SoundEvent.IsLowPrioritySound(sound)) { pos = SoundEvent.GetCameraScaledPosition(pos); if (Grid.Element != null) { bool isLiquid = Grid.Element[num].IsLiquid; float num2 = 0f; if (isLiquid) { num2 = SoundUtil.GetLiquidDepth(num); string sound2 = GlobalAssets.GetSound("Liquid_footstep", true); if (sound2 != null) { FMOD.Studio.EventInstance instance = SoundEvent.BeginOneShot(sound2, pos); if (num2 > 0f) { instance.setParameterValue("liquidDepth", num2); } SoundEvent.EndOneShot(instance); } } if (sound != null) { FMOD.Studio.EventInstance instance2 = SoundEvent.BeginOneShot(sound, pos); if (instance2.isValid()) { if (num2 > 0f) { instance2.setParameterValue("liquidDepth", num2); } if (behaviour.currentAnimFile != null && behaviour.currentAnimFile.Contains("anim_loco_walk")) { instance2.setVolume(IDLE_WALKING_VOLUME_REDUCTION); } SoundEvent.EndOneShot(instance2); } } } } }