private void Update() { if (numWaitFrames <= Time.renderedFrameCount) { if (!SystemInfo.SupportsTextureFormat(TextureFormat.RGBAFloat)) { Debug.LogError("Machine does not support RGBAFloat32"); } GraphicsOptionsScreen.SetResolutionFromPrefs(); Util.ApplyInvariantCultureToThread(Thread.CurrentThread); Debug.Log("release Build: LU-" + 365655.ToString()); UnityEngine.Object.DontDestroyOnLoad(base.gameObject); KPlayerPrefs.instance.Load(); KFMOD.Initialize(); for (int i = 0; i < SpawnPrefabs.Length; i++) { GameObject gameObject = SpawnPrefabs[i]; if ((UnityEngine.Object)gameObject != (UnityEngine.Object)null) { Util.KInstantiate(gameObject, base.gameObject, null); } } DeleteLingeringFiles(); base.enabled = false; } }
protected void PlayCircuitSound(string state) { string sound = null; if (state == "powered") { sound = Sounds.Instance.BuildingPowerOnMigrated; } else if (state == "overdraw") { sound = Sounds.Instance.ElectricGridOverloadMigrated; } else { Debug.Log("Invalid state for sound in EnergyConsumer."); } if (CameraController.Instance.IsAudibleSound(base.transform.GetPosition())) { if (!lastTimeSoundPlayed.TryGetValue(state, out float value)) { value = 0f; } float value2 = (Time.time - value) / soundDecayTime; FMOD.Studio.EventInstance instance = KFMOD.BeginOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(base.transform.GetPosition())); instance.setParameterValue("timeSinceLast", value2); KFMOD.EndOneShot(instance); lastTimeSoundPlayed[state] = Time.time; } }
private void PlayDingSound(Notification notification, int count) { if (!notificationSounds.TryGetValue(notification.Type, out string value)) { value = "Notification"; } if (!timeOfLastNotification.TryGetValue(value, out float value2)) { value2 = 0f; } float value3 = (Time.time - value2) / soundDecayTime; timeOfLastNotification[value] = Time.time; string sound; if (count > 1) { sound = GlobalAssets.GetSound(value + "_AddCount", true); if (sound == null) { sound = GlobalAssets.GetSound(value, false); } } else { sound = GlobalAssets.GetSound(value, false); } if (notification.playSound) { EventInstance instance = KFMOD.BeginOneShot(sound, Vector3.zero); instance.setParameterValue("timeSinceLast", value3); KFMOD.EndOneShot(instance); } }
public static void StopSound(HandleVector <int> .Handle handle) { if (!((UnityEngine.Object)Get() == (UnityEngine.Object)null)) { Sound data = Get().sounds.GetData(handle); if (data.IsPlaying) { data.ev.stop(STOP_MODE.ALLOWFADEOUT); data.ev.release(); SoundDescription soundEventDescription = KFMOD.GetSoundEventDescription(data.path); SoundDescription.Parameter[] parameters = soundEventDescription.parameters; for (int i = 0; i < parameters.Length; i++) { SoundDescription.Parameter parameter = parameters[i]; LoopingSoundParameterUpdater value = null; if (Get().parameterUpdaters.TryGetValue(parameter.name, out value)) { LoopingSoundParameterUpdater.Sound sound = default(LoopingSoundParameterUpdater.Sound); sound.ev = data.ev; sound.path = data.path; sound.description = soundEventDescription; sound.transform = data.transform; LoopingSoundParameterUpdater.Sound sound2 = sound; value.Remove(sound2); } } } Get().sounds.Free(handle); } }
private void PlaySound(SoundType soundType) { if (currentSounds.ContainsKey(soundType)) { KFMOD.PlayOneShot(currentSounds[soundType]); } }
private void Emit(object data) { GameObject gameObject = (GameObject)data; global::Components.Cmps <MinionIdentity> liveMinionIdentities = global::Components.LiveMinionIdentities; Vector2 a = gameObject.transform.GetPosition(); for (int i = 0; i < liveMinionIdentities.Count; i++) { MinionIdentity minionIdentity = liveMinionIdentities[i]; if (minionIdentity.gameObject != gameObject.gameObject) { Vector2 b = minionIdentity.transform.GetPosition(); float num = Vector2.SqrMagnitude(a - b); if (num <= 2.25f) { minionIdentity.Trigger((int)GameHashes.Cringe, Strings.Get("STRINGS.DUPLICANTS.DISEASES.PUTRIDODOUR.CRINGE_EFFECT").String); minionIdentity.gameObject.GetSMI <ThoughtGraph.Instance>().AddThought(Db.Get().Thoughts.PutridOdour); } } } int gameCell = Grid.PosToCell(gameObject.transform.GetPosition()); float temp = Db.Get().Amounts.Temperature.Lookup(this).value; SimMessages.AddRemoveSubstance(gameCell, SimHashes.ContaminatedOxygen, CellEventLogger.Instance.ElementConsumerSimUpdate, 0.0025f, temp, DiseaseInfo.Invalid.idx, DiseaseInfo.Invalid.count); KFMOD.PlayOneShot(GlobalAssets.GetSound("Dupe_Flatulence"), base.transform.GetPosition()); }
// штуки для создания сидескреенов // чекбокс и слидер с обвязкой и подгрузкой строк, добавляемые на панельку // установка и считывание значений реализованы через акции-каллбаки public static PPanel AddCheckBox(this PPanel parent, string prefix, string name, Action <bool> onChecked, out Action <bool> setChecked, out Action <bool> setActive) { prefix = (prefix + name).ToUpperInvariant(); GameObject cb_go = null; var cb = new PCheckBox(name) { CheckColor = PUITuning.Colors.ComponentLightStyle, CheckSize = new Vector2(26f, 26f), Text = Strings.Get(prefix + ".NAME"), TextAlignment = TextAnchor.MiddleLeft, TextStyle = PUITuning.Fonts.TextDarkStyle, ToolTip = Strings.Get(prefix + ".TOOLTIP"), OnChecked = (go, state) => { // переворачиваем предыдующее значение bool @checked = state == PCheckBox.STATE_UNCHECKED; PCheckBox.SetCheckState(go, @checked ? PCheckBox.STATE_CHECKED : PCheckBox.STATE_UNCHECKED); onChecked?.Invoke(@checked); // внесапно, численное значение состояния чекбокса совпало с индексом таблицы звуков KFMOD.PlayUISound(WidgetSoundPlayer.getSoundPath(ToggleSoundPlayer.default_values[state])); }, }.AddOnRealize(realized => cb_go = realized); setChecked = @checked => { if (cb_go != null) { PCheckBox.SetCheckState(cb_go, @checked ? PCheckBox.STATE_CHECKED : PCheckBox.STATE_UNCHECKED); } }; setActive = on => cb_go?.SetActive(on); return(parent.AddChild(cb)); }
public void Start(Vector3 emitter_position) { if (!isRunning) { if (oneShotSound != null) { EventInstance eventInstance = KFMOD.CreateInstance(oneShotSound); if (!eventInstance.isValid()) { Debug.LogWarning("Could not find event: " + oneShotSound); } else { Vector3 pos = new Vector3(emitter_position.x, emitter_position.y, 0f); ATTRIBUTES_3D attributes = pos.To3DAttributes(); eventInstance.set3DAttributes(attributes); eventInstance.setVolume(tilePercentage * 2f); eventInstance.start(); eventInstance.release(); } } else { soundEvent = KFMOD.CreateInstance(sound); if (soundEvent.isValid()) { soundEvent.start(); } isRunning = true; } } }
public override void OnKeyDown(KButtonEvent e) { if (e.TryConsume(Action.RotateBuilding)) { if ((Object)visualizer != (Object)null) { Rotatable component = visualizer.GetComponent <Rotatable>(); if ((Object)component != (Object)null) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Rotate", false)); buildingOrientation = component.Rotate(); if (Grid.IsValidBuildingCell(lastCell)) { Vector3 pos = Grid.CellToPosCCC(lastCell, Grid.SceneLayer.Building); UpdateVis(pos); } if (base.Dragging && lastDragCell != -1) { TryBuild(lastDragCell); } } } } else { base.OnKeyDown(e); } }
private void TriggerAudio(int old_value) { SpeedControlScreen instance = SpeedControlScreen.Instance; if (old_value != outputValue && (Object)instance != (Object)null && !instance.IsPaused) { GridArea visibleArea = GridVisibleArea.GetVisibleArea(); List <LogicWire> list = new List <LogicWire>(); for (int i = 0; i < wires.Count; i++) { if (visibleArea.Min <= (Vector2)wires[i].transform.GetPosition() && (Vector2)wires[i].transform.GetPosition() <= visibleArea.Max) { list.Add(wires[i]); } } if (list.Count > 0) { int index = Mathf.CeilToInt((float)(list.Count / 2)); if ((Object)list[index] != (Object)null) { Vector3 position = list[index].transform.GetPosition(); EventInstance instance2 = KFMOD.BeginOneShot(GlobalAssets.GetSound("Logic_Circuit_Toggle", false), position); instance2.setParameterValue("wireCount", (float)(wires.Count % 24)); instance2.setParameterValue("enabled", (float)outputValue); KFMOD.EndOneShot(instance2); } } } }
private void PlayTone(int pitch, bool forwards) { EventInstance instance = KFMOD.BeginOneShot(GlobalAssets.GetSound("WorkChime_tone", false), Vector3.zero); instance.setParameterValue("WorkChime_pitch", (float)pitch); instance.setParameterValue("WorkChime_start", (float)(forwards ? 1 : 0)); KFMOD.EndOneShot(instance); }
private void OnDiscoveredSpaceClicked() { KFMOD.PlayOneShot(GlobalAssets.GetSound(GetSound(), false)); MusicManager.instance.PlaySong("Stinger_Surface", false); CameraController.Instance.SetTargetPos(cameraFocusPos, 8f, true); SeasonManager component = SaveGame.Instance.GetComponent <SeasonManager>(); component.ForceBeginMeteorSeasonWithShower(); }
protected override void OnSpawn() { base.OnSpawn(); techViewSound = KFMOD.CreateInstance(techViewSoundPath); techViewSoundPlaying = false; Shader.SetGlobalVector("_OverlayParams", Vector4.zero); RegisterModes(); currentModeInfo = modeInfos[OverlayModes.None.ID]; }
public override void PlaySound(AnimEventManager.EventPlayerData behaviour) { EventInstance instance = KFMOD.BeginOneShot(base.sound, Vector3.zero); if (instance.isValid()) { instance.setParameterValue("frame", (float)base.frame); KFMOD.EndOneShot(instance); } }
public void PlayStartSound() { if (KInputManager.isFocused && playSounds) { string text = currentSounds[0]; if (text != null && text.Length > 0) { KFMOD.PlayOneShot(text); } } }
public void Select(KSelectable new_selected, bool skipSound = false) { if (!((Object)new_selected == (Object)previousSelection)) { previousSelection = new_selected; if ((Object)selected != (Object)null) { selected.Unselect(); } GameObject gameObject = null; if ((Object)new_selected != (Object)null) { SelectToolHoverTextCard component = GetComponent <SelectToolHoverTextCard>(); if ((Object)component != (Object)null) { int currentSelectedSelectableIndex = component.currentSelectedSelectableIndex; int recentNumberOfDisplayedSelectables = component.recentNumberOfDisplayedSelectables; if (recentNumberOfDisplayedSelectables != 0) { currentSelectedSelectableIndex = (currentSelectedSelectableIndex + 1) % recentNumberOfDisplayedSelectables; if (!skipSound) { if (recentNumberOfDisplayedSelectables == 1) { KFMOD.PlayOneShot(GlobalAssets.GetSound("Select_empty", false)); } else { EventInstance instance = KFMOD.BeginOneShot(GlobalAssets.GetSound("Select_full", false), Vector3.zero); instance.setParameterValue("selection", (float)currentSelectedSelectableIndex); SoundEvent.EndOneShot(instance); } playedSoundThisFrame = true; } } } if ((Object)new_selected == (Object)hover) { ClearHover(); } new_selected.Select(); gameObject = new_selected.gameObject; selectMarker.SetTargetTransform(gameObject.transform); selectMarker.gameObject.SetActive(!new_selected.DisableSelectMarker); } else if ((Object)selectMarker != (Object)null) { selectMarker.gameObject.SetActive(false); } selected = new_selected; Game.Instance.Trigger(-1503271301, gameObject); } }
public void PlayEndSound() { if (KInputManager.isFocused && playSounds) { string text = currentSounds[2]; if (text != null && text.Length > 0) { EventInstance instance = KFMOD.BeginOneShot(text, Vector3.zero); instance.setParameterValue("sliderValue", value); KFMOD.EndOneShot(instance); } } }
private void PlayClickSound() { if (play_sound_on_click) { if (states[state].on_click_override_sound_path == string.Empty) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Click", false)); } else { KFMOD.PlayOneShot(GlobalAssets.GetSound(states[state].on_click_override_sound_path, false)); } } }
private void PlayTileDamageSound(Element element, Vector3 pos) { string text = element.substance.GetMiningBreakSound(); if (text == null) { text = (element.HasTag(GameTags.RefinedMetal) ? "RefinedMetal" : ((!element.HasTag(GameTags.Metal)) ? "Rock" : "RawMetal")); } text = "MeteorDamage_" + text; text = GlobalAssets.GetSound(text, false); if ((bool)CameraController.Instance && CameraController.Instance.IsAudibleSound(pos, text)) { KFMOD.PlayOneShot(text, CameraController.Instance.GetVerticallyScaledPosition(pos)); } }
public virtual void OnPointerDown(PointerEventData eventData) { clickHeldDown = true; if (play_sound_on_click) { if (states[state].on_click_override_sound_path == string.Empty) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Click", false)); } else { KFMOD.PlayOneShot(GlobalAssets.GetSound(states[state].on_click_override_sound_path, false)); } } }
public virtual void OnPointerUp(PointerEventData eventData) { if (clickHeldDown) { if (play_sound_on_release && states[state].on_release_override_sound_path != string.Empty) { KFMOD.PlayOneShot(GlobalAssets.GetSound(states[state].on_release_override_sound_path, false)); } clickHeldDown = false; if (onStopHold != null) { onStopHold(); } } totalHeldTime = 0f; }
private void PlayImpactSound(Vector3 pos) { if (impactSound == null) { impactSound = "Meteor_Large_Impact"; } loopingSounds.StopSound(flyingSound); string sound = GlobalAssets.GetSound(impactSound, false); if (CameraController.Instance.IsAudibleSound(pos, sound)) { EventInstance instance = KFMOD.BeginOneShot(sound, pos); instance.setParameterValue("userVolume_SFX", KPlayerPrefs.GetFloat("Volume_SFX")); KFMOD.EndOneShot(instance); } }
private void TriggerAudio(int new_value) { LogicCircuitNetwork networkForCell = Game.Instance.logicCircuitManager.GetNetworkForCell(cell); SpeedControlScreen instance = SpeedControlScreen.Instance; if (networkForCell != null && new_value != value && (UnityEngine.Object)instance != (UnityEngine.Object)null && !instance.IsPaused && (!KPlayerPrefs.HasKey(AudioOptionsScreen.AlwaysPlayAutomation) || KPlayerPrefs.GetInt(AudioOptionsScreen.AlwaysPlayAutomation) == 1 || !(OverlayScreen.Instance.GetMode() != OverlayModes.Logic.ID))) { string name = "Logic_Building_Toggle"; if (CameraController.Instance.IsAudibleSound(Grid.CellToPosCCC(cell, Grid.SceneLayer.BuildingFront))) { EventInstance instance2 = KFMOD.BeginOneShot(GlobalAssets.GetSound(name, false), Grid.CellToPos(cell)); instance2.setParameterValue("wireCount", (float)(networkForCell.Wires.Count % 24)); instance2.setParameterValue("enabled", (float)new_value); KFMOD.EndOneShot(instance2); } } }
public void OnPointerDown(PointerEventData eventData) { MinionIdentity minionIdentity = skillsScreen.CurrentlySelectedMinion as MinionIdentity; MinionResume component = minionIdentity.GetComponent <MinionResume>(); MinionResume.SkillMasteryConditions[] skillMasteryConditions = component.GetSkillMasteryConditions(skillID); bool flag = component.CanMasterSkill(skillMasteryConditions); if ((UnityEngine.Object)component != (UnityEngine.Object)null && !component.HasMasteredSkill(skillID) && flag) { KFMOD.PlayOneShot(GlobalAssets.GetSound("HUD_Click", false)); } else { KFMOD.PlayOneShot(GlobalAssets.GetSound("Negative", false)); } }
public void PlayMoveSound(MoveSource moveSource) { if (KInputManager.isFocused && playSounds) { float num = Time.unscaledTime - lastMoveTime; if (!(num < movePlayRate)) { if (moveSource != MoveSource.MouseDrag) { playedBoundaryBump = false; } float num2 = Mathf.InverseLerp(base.minValue, base.maxValue, value); string text = null; if (num2 == 1f && lastMoveValue == 1f) { if (!playedBoundaryBump) { text = currentSounds[4]; playedBoundaryBump = true; } } else if (num2 == 0f && lastMoveValue == 0f) { if (!playedBoundaryBump) { text = currentSounds[3]; playedBoundaryBump = true; } } else if (num2 >= 0f && num2 <= 1f) { text = currentSounds[1]; playedBoundaryBump = false; } if (text != null && text.Length > 0) { lastMoveTime = Time.unscaledTime; lastMoveValue = num2; EventInstance instance = KFMOD.BeginOneShot(text, Vector3.zero); instance.setParameterValue("sliderValue", num2); instance.setParameterValue("timeSinceLast", num); KFMOD.EndOneShot(instance); } } } }
private void PlayBuildingDamageSound(BuildingDef def, Vector3 pos) { if ((Object)def != (Object)null) { string name = StringFormatter.Combine("MeteorDamage_Building_", def.AudioCategory); string sound = GlobalAssets.GetSound(name, false); if (sound == null) { name = "MeteorDamage_Building_Metal"; sound = GlobalAssets.GetSound(name, false); } if (sound != null && (bool)CameraController.Instance && CameraController.Instance.IsAudibleSound(pos, sound)) { KFMOD.PlayOneShot(sound, CameraController.Instance.GetVerticallyScaledPosition(pos)); } } }
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); } } } } } }
// Based on Ksliders sounds // Minor bug: the pitch is a little too high public void PlayMoveSound() { if (KInputManager.isFocused) { float timeSinceLast = Time.unscaledTime - lastMoveTime; if (!(timeSinceLast < movePlayRate)) { float inverseLerpValue = Mathf.InverseLerp(slider.minValue, slider.maxValue, slider.value); string sound_path = null; if (inverseLerpValue == 1f && lastMoveValue == 1f) { if (!playedBoundaryBump) { sound_path = UISoundHelper.SliderBoundaryHigh; playedBoundaryBump = true; } } else { if (inverseLerpValue == 0f && lastMoveValue == 0f) { if (!playedBoundaryBump) { sound_path = UISoundHelper.SliderBoundaryLow; playedBoundaryBump = true; } } else if (inverseLerpValue >= 0f && inverseLerpValue <= 1f) { sound_path = UISoundHelper.SliderMove; playedBoundaryBump = false; } } if (sound_path != null && sound_path.Length > 0) { lastMoveTime = Time.unscaledTime; lastMoveValue = inverseLerpValue; FMOD.Studio.EventInstance ev = KFMOD.BeginOneShot(sound_path, Vector3.zero, 1f); ev.setParameterValue("sliderValue", inverseLerpValue); ev.setParameterValue("timeSinceLast", timeSinceLast); KFMOD.EndOneShot(ev); } } } }
public EventInstance Start(string snapshot) { if (!activeSnapshots.TryGetValue(snapshot, out EventInstance value)) { if (RuntimeManager.IsInitialized) { value = KFMOD.CreateInstance(snapshot); activeSnapshots[snapshot] = value; value.start(); value.setParameterValue("snapshotActive", 1f); } else { value = default(EventInstance); } } instance.Log("Start Snapshot: " + snapshot); return(value); }
public void Play(int sound_event_idx) { if (Enabled) { WidgetSoundEvent widgetSoundEvent = default(WidgetSoundEvent); for (int i = 0; i < widget_sound_events().Length; i++) { if (sound_event_idx == widget_sound_events()[i].idx) { widgetSoundEvent = widget_sound_events()[sound_event_idx]; break; } } if (KInputManager.isFocused && widgetSoundEvent.PlaySound && widgetSoundEvent.Name != null && widgetSoundEvent.Name.Length >= 0 && !(widgetSoundEvent.Name == string.Empty)) { KFMOD.PlayOneShot(getSoundPath((!(widgetSoundEvent.OverrideAssetName == string.Empty)) ? widgetSoundEvent.OverrideAssetName : GetDefaultPath(widgetSoundEvent.idx))); } } }