private void TriggerLoadingMusic()
 {
     if (AudioDebug.Get().musicEnabled&& !MusicManager.instance.SongIsPlaying("Music_FrontEnd"))
     {
         MusicManager.instance.StopSong("Music_TitleTheme", true, STOP_MODE.ALLOWFADEOUT);
         AudioMixer.instance.Stop(AudioMixerSnapshots.Get().FrontEndSnapshot, STOP_MODE.ALLOWFADEOUT);
         AudioMixer.instance.Start(AudioMixerSnapshots.Get().FrontEndWorldGenerationSnapshot);
         MusicManager.instance.PlaySong("Music_FrontEnd", false);
         MusicManager.instance.SetSongParameter("Music_FrontEnd", "songSection", 1f, true);
     }
 }
コード例 #2
0
 public void StartFEAudio()
 {
     AudioMixer.instance.Reset();
     AudioMixer.instance.Start(AudioMixerSnapshots.Get().FrontEndSnapshot);
     if (!AudioMixer.instance.SnapshotIsActive(AudioMixerSnapshots.Get().UserVolumeSettingsSnapshot))
     {
         AudioMixer.instance.StartUserVolumesSnapshot();
     }
     if (AudioDebug.Get().musicEnabled&& !MusicManager.instance.SongIsPlaying("Music_TitleTheme"))
     {
         MusicManager.instance.PlaySong("Music_TitleTheme", false);
     }
     CheckForAudioDriverIssue();
 }
コード例 #3
0
    public void PlayEvent(GameSoundEvents.Event ev)
    {
        if (AudioDebug.Get().debugGameEventSounds)
        {
            Debug.Log("GameSoundEvent: " + ev.Name);
        }
        List <AnimEvent> events = GameAudioSheets.Get().GetEvents(ev.Name);

        if (events != null)
        {
            Vector2 v = base.transform.GetPosition();
            for (int i = 0; i < events.Count; i++)
            {
                AnimEvent  animEvent  = events[i];
                SoundEvent soundEvent = animEvent as SoundEvent;
                if (soundEvent == null || soundEvent.sound == null)
                {
                    break;
                }
                if (CameraController.Instance.IsAudibleSound(v, soundEvent.sound))
                {
                    if (AudioDebug.Get().debugGameEventSounds)
                    {
                        Debug.Log("GameSound: " + soundEvent.sound);
                    }
                    float value = 0f;
                    if (lastTimePlayed.TryGetValue(soundEvent.soundHash, out value))
                    {
                        if (Time.time - value > soundEvent.minInterval)
                        {
                            SoundEvent.PlayOneShot(soundEvent.sound, v);
                        }
                    }
                    else
                    {
                        SoundEvent.PlayOneShot(soundEvent.sound, v);
                    }
                    lastTimePlayed[soundEvent.soundHash] = Time.time;
                }
            }
        }
    }
    private void AddNotification(Notification notification)
    {
        notifications.Add(notification);
        notification.Idx = notificationIncrement++;
        Entry entry = null;

        entriesByMessage.TryGetValue(notification.titleText, out entry);
        if (entry == null)
        {
            GameObject label;
            if (notification.Type == NotificationType.Messages)
            {
                label = Util.KInstantiateUI(MessagesPrefab, MessagesFolder, false);
            }
            else
            {
                label = Util.KInstantiateUI(LabelPrefab, LabelsFolder, false);
            }
            label.GetComponentInChildren <NotificationAnimator>().Init();
            label.gameObject.SetActive(true);
            KImage     componentInChildren  = label.GetComponentInChildren <KImage>(true);
            Button[]   componentsInChildren = label.gameObject.GetComponentsInChildren <Button>();
            ColorBlock colors = componentsInChildren[0].colors;
            if (notification.Type == NotificationType.Bad || notification.Type == NotificationType.DuplicantThreatening)
            {
                colors.normalColor = badColorBG;
            }
            else if (notification.Type == NotificationType.Messages)
            {
                colors.normalColor = messageColorBG;
                Debug.Assert(notification.GetType() == typeof(MessageNotification), $"Notification: \"{notification.titleText}\" is not of type MessageNotification");
                componentsInChildren[1].onClick.AddListener(delegate
                {
                    List <Notification> list = notifications.FindAll((Notification n) => n.titleText == notification.titleText);
                    foreach (Notification item in list)
                    {
                        MessageNotification messageNotification = (MessageNotification)item;
                        Messenger.Instance.RemoveMessage(messageNotification.message);
                        messageNotification.Clear();
                    }
                });
            }
            else if (notification.Type == NotificationType.Tutorial)
            {
                colors.normalColor = warningColorBG;
            }
            else
            {
                colors.normalColor = normalColorBG;
            }
            componentsInChildren[0].colors = colors;
            componentsInChildren[0].onClick.AddListener(delegate
            {
                OnClick(entry);
            });
            if (notification.ToolTip != null)
            {
                label.GetComponentInChildren <ToolTip>().OnToolTip = delegate
                {
                    ToolTip componentInChildren2 = label.GetComponentInChildren <ToolTip>();
                    componentInChildren2.ClearMultiStringTooltip();
                    componentInChildren2.AddMultiStringTooltip(notification.ToolTip(entry.notifications, notification.tooltipData), TooltipTextStyle);
                    return(string.Empty);
                };
            }
            entry = new Entry(label);
            entriesByMessage[notification.titleText] = entry;
            entries.Add(entry);
            LocText[] componentsInChildren2 = label.GetComponentsInChildren <LocText>();
            LocText[] array = componentsInChildren2;
            foreach (LocText locText in array)
            {
                switch (notification.Type)
                {
                case NotificationType.Bad:
                    locText.color = badColor;
                    componentInChildren.sprite = icon_bad;
                    break;

                case NotificationType.DuplicantThreatening:
                    locText.color = badColor;
                    componentInChildren.sprite = icon_bad;
                    break;

                case NotificationType.Tutorial:
                    locText.color = warningColor;
                    componentInChildren.sprite = icon_warning;
                    break;

                case NotificationType.Messages:
                    locText.color = messageColor;
                    componentInChildren.sprite = icon_message;
                    break;

                default:
                    locText.color = normalColor;
                    componentInChildren.sprite = icon_normal;
                    break;
                }
                componentInChildren.color = locText.color;
                string str = string.Empty;
                if (KTime.Instance.UnscaledGameTime - initTime > 5f && notification.playSound)
                {
                    PlayDingSound(notification, 0);
                }
                else
                {
                    str = "too early";
                }
                if (AudioDebug.Get().debugNotificationSounds)
                {
                    Debug.Log("Notification(" + notification.titleText + "):" + str);
                }
            }
        }
        entry.Add(notification);
        entry.UpdateMessage(notification, true);
        dirty = true;
        SortNotifications();
    }
コード例 #5
0
 public void PlaySong(string song_name, bool canWait = false)
 {
     Log("Play: " + song_name);
     if (AudioDebug.Get().musicEnabled)
     {
         SongInfo value = null;
         if (!songMap.TryGetValue(song_name, out value))
         {
             DebugUtil.LogErrorArgs("Unknown song:", song_name);
         }
         else if (activeSongs.ContainsKey(song_name))
         {
             DebugUtil.LogWarningArgs("Trying to play duplicate song:", song_name);
         }
         else if (activeSongs.Count == 0)
         {
             value.ev = KFMOD.CreateInstance(value.fmodEvent);
             if (!value.ev.isValid())
             {
                 DebugUtil.LogWarningArgs("Failed to find FMOD event [" + value.fmodEvent + "]");
             }
             int num = (value.numberOfVariations <= 0) ? (-1) : UnityEngine.Random.Range(1, value.numberOfVariations + 1);
             if (num != -1)
             {
                 value.ev.setParameterValue("variation", (float)num);
             }
             value.ev.start();
             activeSongs[song_name] = value;
             if (value.dynamic)
             {
                 activeDynamicSong = value;
             }
         }
         else
         {
             List <string> list = new List <string>(activeSongs.Keys);
             if (value.interruptsActiveMusic)
             {
                 for (int i = 0; i < list.Count; i++)
                 {
                     if (!activeSongs[list[i]].interruptsActiveMusic)
                     {
                         SongInfo songInfo = activeSongs[list[i]];
                         songInfo.ev.setParameterValue("interrupted_dimmed", 1f);
                         Log("Dimming: " + Assets.GetSimpleSoundEventName(songInfo.fmodEvent));
                         value.songsOnHold.Add(list[i]);
                     }
                 }
                 value.ev = KFMOD.CreateInstance(value.fmodEvent);
                 if (!value.ev.isValid())
                 {
                     DebugUtil.LogWarningArgs("Failed to find FMOD event [" + value.fmodEvent + "]");
                 }
                 value.ev.start();
                 value.ev.release();
                 activeSongs[song_name] = value;
             }
             else
             {
                 int num2 = 0;
                 foreach (string key in activeSongs.Keys)
                 {
                     SongInfo songInfo2 = activeSongs[key];
                     if (!songInfo2.interruptsActiveMusic && songInfo2.priority > num2)
                     {
                         num2 = songInfo2.priority;
                     }
                 }
                 if (value.priority >= num2)
                 {
                     for (int j = 0; j < list.Count; j++)
                     {
                         SongInfo songInfo3           = activeSongs[list[j]];
                         FMOD.Studio.EventInstance ev = songInfo3.ev;
                         if (!songInfo3.interruptsActiveMusic)
                         {
                             ev.setParameterValue("interrupted_dimmed", 1f);
                             ev.stop(STOP_MODE.ALLOWFADEOUT);
                             activeSongs.Remove(list[j]);
                             list.Remove(list[j]);
                         }
                     }
                     value.ev = KFMOD.CreateInstance(value.fmodEvent);
                     if (!value.ev.isValid())
                     {
                         DebugUtil.LogWarningArgs("Failed to find FMOD event [" + value.fmodEvent + "]");
                     }
                     int num3 = (value.numberOfVariations <= 0) ? (-1) : UnityEngine.Random.Range(1, value.numberOfVariations + 1);
                     if (num3 != -1)
                     {
                         value.ev.setParameterValue("variation", (float)num3);
                     }
                     value.ev.start();
                     activeSongs[song_name] = value;
                 }
             }
         }
     }
 }
コード例 #6
0
    public void OnKeyDown(KButtonEvent e)
    {
        if (!enabled)
        {
            return;
        }
        if (e.TryConsume(Action.DebugSpawnMinion))
        {
            SpawnMinion();
        }
        else if (e.TryConsume(Action.DebugSpawnStressTest))
        {
            for (int i = 0; i < 60; i++)
            {
                SpawnMinion();
            }
        }
        else if (e.TryConsume(Action.DebugSuperTestMode))
        {
            if (!superTestMode)
            {
                Time.timeScale = 15f;
                superTestMode  = true;
            }
            else
            {
                Time.timeScale = 1f;
                superTestMode  = false;
            }
        }
        else if (e.TryConsume(Action.DebugUltraTestMode))
        {
            if (!ultraTestMode)
            {
                Time.timeScale = 30f;
                ultraTestMode  = true;
            }
            else
            {
                Time.timeScale = 1f;
                ultraTestMode  = false;
            }
        }
        else if (e.TryConsume(Action.DebugSlowTestMode))
        {
            if (!slowTestMode)
            {
                Time.timeScale = 0.06f;
                slowTestMode   = true;
            }
            else
            {
                Time.timeScale = 1f;
                slowTestMode   = false;
            }
        }
        else if (e.TryConsume(Action.DebugDig))
        {
            int mouseCell = GetMouseCell();
            SimMessages.Dig(mouseCell, -1);
        }
        else if (e.TryConsume(Action.DebugInstantBuildMode))
        {
            InstantBuildMode = !InstantBuildMode;
            if ((UnityEngine.Object)Game.Instance == (UnityEngine.Object)null)
            {
                return;
            }
            if ((UnityEngine.Object)PlanScreen.Instance != (UnityEngine.Object)null)
            {
                PlanScreen.Instance.Refresh();
            }
            if ((UnityEngine.Object)BuildMenu.Instance != (UnityEngine.Object)null)
            {
                BuildMenu.Instance.Refresh();
            }
            if ((UnityEngine.Object)OverlayMenu.Instance != (UnityEngine.Object)null)
            {
                OverlayMenu.Instance.Refresh();
            }
            if ((UnityEngine.Object)ConsumerManager.instance != (UnityEngine.Object)null)
            {
                ConsumerManager.instance.RefreshDiscovered(null);
            }
            if ((UnityEngine.Object)ManagementMenu.Instance != (UnityEngine.Object)null)
            {
                ManagementMenu.Instance.CheckResearch(null);
                ManagementMenu.Instance.CheckSkills(null);
                ManagementMenu.Instance.CheckStarmap(null);
            }
            Game.Instance.Trigger(1594320620, "all_the_things");
        }
        else if (e.TryConsume(Action.DebugExplosion))
        {
            Vector3 mousePos = KInputManager.GetMousePos();
            Vector3 position = Camera.main.transform.GetPosition();
            mousePos.z = 0f - position.z - Grid.CellSizeInMeters;
            Vector3 explosion_pos = Camera.main.ScreenToWorldPoint(mousePos);
            GameUtil.CreateExplosion(explosion_pos);
        }
        else if (e.TryConsume(Action.DebugLockCursor))
        {
            if (GenericGameSettings.instance.developerDebugEnable)
            {
                KInputManager.isMousePosLocked = !KInputManager.isMousePosLocked;
                KInputManager.lockedMousePos   = KInputManager.GetMousePos();
            }
        }
        else if (e.TryConsume(Action.DebugDiscoverAllElements))
        {
            if ((UnityEngine.Object)WorldInventory.Instance != (UnityEngine.Object)null)
            {
                foreach (Element element in ElementLoader.elements)
                {
                    WorldInventory.Instance.Discover(element.tag, element.GetMaterialCategoryTag());
                }
            }
        }
        else if (e.TryConsume(Action.DebugToggleUI))
        {
            ToggleScreenshotMode();
        }
        else if (e.TryConsume(Action.SreenShot1x))
        {
            string filename = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename, 1);
        }
        else if (e.TryConsume(Action.SreenShot2x))
        {
            string filename2 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename2, 2);
        }
        else if (e.TryConsume(Action.SreenShot8x))
        {
            string filename3 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename3, 8);
        }
        else if (e.TryConsume(Action.SreenShot32x))
        {
            string filename4 = Path.ChangeExtension(SaveLoader.GetActiveSaveFilePath(), ".png");
            ScreenCapture.CaptureScreenshot(filename4, 32);
        }
        else if (e.TryConsume(Action.DebugCellInfo))
        {
            DebugCellInfo = !DebugCellInfo;
        }
        else if (e.TryConsume(Action.DebugToggle))
        {
            if ((UnityEngine.Object)Game.Instance != (UnityEngine.Object)null)
            {
                Game.Instance.UpdateGameActiveRegion(0, 0, Grid.WidthInCells, Grid.HeightInCells);
                SaveGame.Instance.worldGenSpawner.SpawnEverything();
            }
            if ((UnityEngine.Object)DebugPaintElementScreen.Instance != (UnityEngine.Object)null)
            {
                bool activeSelf = DebugPaintElementScreen.Instance.gameObject.activeSelf;
                DebugPaintElementScreen.Instance.gameObject.SetActive(!activeSelf);
                if ((bool)DebugElementMenu.Instance && DebugElementMenu.Instance.root.activeSelf)
                {
                    DebugElementMenu.Instance.root.SetActive(false);
                }
                DebugBaseTemplateButton.Instance.gameObject.SetActive(!activeSelf);
                PropertyTextures.FogOfWarScale = (float)((!activeSelf) ? 1 : 0);
                if ((UnityEngine.Object)CameraController.Instance != (UnityEngine.Object)null)
                {
                    CameraController.Instance.EnableFreeCamera(!activeSelf);
                }
            }
        }
        else if (e.TryConsume(Action.DebugCollectGarbage))
        {
            GC.Collect();
        }
        else if (e.TryConsume(Action.DebugInvincible))
        {
            InvincibleMode = !InvincibleMode;
        }
        else if (e.TryConsume(Action.DebugVisualTest))
        {
            Scenario.Instance.SetupVisualTest();
        }
        else if (e.TryConsume(Action.DebugGameplayTest))
        {
            Scenario.Instance.SetupGameplayTest();
        }
        else if (e.TryConsume(Action.DebugElementTest))
        {
            Scenario.Instance.SetupElementTest();
        }
        else if (e.TryConsume(Action.ToggleProfiler))
        {
            Sim.SIM_HandleMessage(-409964931, 0, null);
        }
        else if (e.TryConsume(Action.DebugRefreshNavCell))
        {
            Pathfinding.Instance.RefreshNavCell(GetMouseCell());
        }
        else if (e.TryConsume(Action.DebugToggleSelectInEditor))
        {
            SetSelectInEditor(!SelectInEditor);
        }
        else if (e.TryConsume(Action.DebugGotoTarget))
        {
            Debug.Log("Debug GoTo");
            Game.Instance.Trigger(775300118, null);
            foreach (Brain item in Components.Brains.Items)
            {
                item.GetSMI <DebugGoToMonitor.Instance>()?.GoToCursor();
                item.GetSMI <CreatureDebugGoToMonitor.Instance>()?.GoToCursor();
            }
        }
        else if (e.TryConsume(Action.DebugTeleport))
        {
            if ((UnityEngine.Object)SelectTool.Instance == (UnityEngine.Object)null)
            {
                return;
            }
            KSelectable selected = SelectTool.Instance.selected;
            if ((UnityEngine.Object)selected != (UnityEngine.Object)null)
            {
                int mouseCell2 = GetMouseCell();
                if (!Grid.IsValidBuildingCell(mouseCell2))
                {
                    PopFXManager.Instance.SpawnFX(PopFXManager.Instance.sprite_Negative, UI.DEBUG_TOOLS.INVALID_LOCATION, null, GetMousePos(), 1.5f, false, true);
                    return;
                }
                selected.transform.SetPosition(Grid.CellToPosCBC(mouseCell2, Grid.SceneLayer.Move));
            }
        }
        else if (!e.TryConsume(Action.DebugPlace) && !e.TryConsume(Action.DebugSelectMaterial))
        {
            if (e.TryConsume(Action.DebugNotification))
            {
                if (GenericGameSettings.instance.developerDebugEnable)
                {
                    Tutorial.Instance.DebugNotification();
                }
            }
            else if (e.TryConsume(Action.DebugNotificationMessage))
            {
                if (GenericGameSettings.instance.developerDebugEnable)
                {
                    Tutorial.Instance.DebugNotificationMessage();
                }
            }
            else if (e.TryConsume(Action.DebugSuperSpeed))
            {
                if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null)
                {
                    SpeedControlScreen.Instance.ToggleRidiculousSpeed();
                }
            }
            else if (e.TryConsume(Action.DebugGameStep))
            {
                if ((UnityEngine.Object)SpeedControlScreen.Instance != (UnityEngine.Object)null)
                {
                    SpeedControlScreen.Instance.DebugStepFrame();
                }
            }
            else if (e.TryConsume(Action.DebugSimStep))
            {
                Game.Instance.ForceSimStep();
            }
            else if (e.TryConsume(Action.DebugToggleMusic))
            {
                AudioDebug.Get().ToggleMusic();
            }
            else if (e.TryConsume(Action.DebugRiverTest))
            {
                Scenario.Instance.SetupRiverTest();
            }
            else if (e.TryConsume(Action.DebugTileTest))
            {
                Scenario.Instance.SetupTileTest();
            }
            else if (e.TryConsume(Action.DebugForceLightEverywhere))
            {
                PropertyTextures.instance.ForceLightEverywhere = !PropertyTextures.instance.ForceLightEverywhere;
            }
            else if (e.TryConsume(Action.DebugPathFinding))
            {
                DebugPathFinding = !DebugPathFinding;
                Debug.Log("DebugPathFinding=" + DebugPathFinding);
            }
            else if (!e.TryConsume(Action.DebugFocus))
            {
                if (e.TryConsume(Action.DebugReportBug))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        int    num = 0;
                        string validSaveFilename;
                        while (true)
                        {
                            validSaveFilename = SaveScreen.GetValidSaveFilename("bug_report_savefile_" + num.ToString());
                            if (!File.Exists(validSaveFilename))
                            {
                                break;
                            }
                            num++;
                        }
                        string save_file = "No save file (front end)";
                        if ((UnityEngine.Object)SaveLoader.Instance != (UnityEngine.Object)null)
                        {
                            save_file = SaveLoader.Instance.Save(validSaveFilename, false, false);
                        }
                        KCrashReporter.ReportBug("Bug Report", save_file);
                    }
                    else
                    {
                        Debug.Log("Debug crash keys are not enabled.");
                    }
                }
                else if (e.TryConsume(Action.DebugTriggerException))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        string     str        = Guid.NewGuid().ToString();
                        StackTrace stackTrace = new StackTrace(1, true);
                        str = str + "\n" + stackTrace.ToString();
                        KCrashReporter.ReportError("Debug crash with random stack", str, null, ScreenPrefabs.Instance.ConfirmDialogScreen, string.Empty);
                    }
                }
                else if (e.TryConsume(Action.DebugTriggerError))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        Debug.LogError("Oooops! Testing error!");
                    }
                }
                else if (e.TryConsume(Action.DebugDumpGCRoots))
                {
                    GarbageProfiler.DebugDumpRootItems();
                }
                else if (e.TryConsume(Action.DebugDumpGarbageReferences))
                {
                    GarbageProfiler.DebugDumpGarbageStats();
                }
                else if (e.TryConsume(Action.DebugDumpEventData))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        KObjectManager.Instance.DumpEventData();
                    }
                }
                else if (e.TryConsume(Action.DebugDumpSceneParitionerLeakData))
                {
                    if (!GenericGameSettings.instance.developerDebugEnable)
                    {
                        goto IL_0b5e;
                    }
                }
                else if (e.TryConsume(Action.DebugCrashSim))
                {
                    if (GenericGameSettings.instance.developerDebugEnable)
                    {
                        Sim.SIM_DebugCrash();
                    }
                }
                else if (e.TryConsume(Action.DebugNextCall))
                {
                    DebugNextCall = true;
                }
                else if (e.TryConsume(Action.DebugTogglePersonalPriorityComparison))
                {
                    Chore.ENABLE_PERSONAL_PRIORITIES = !Chore.ENABLE_PERSONAL_PRIORITIES;
                }
            }
        }
        goto IL_0b5e;
IL_0b5e:
        if (e.Consumed && (UnityEngine.Object)Game.Instance != (UnityEngine.Object)null)
        {
            Game.Instance.debugWasUsed  = true;
            KCrashReporter.debugWasUsed = true;
        }
    }
コード例 #7
0
 protected override void OnPrefabInit()
 {
     instance = this;
 }