Exemplo n.º 1
0
    /// <summary>
    /// Called whenever the game mode ends.
    /// </summary>
    private void OnMatchEnd(BaseGameMode game_mode)
    {
        BaseGameMode.Instance.MatchCountdownEvent -= OnMatchEnd;

        text_mesh.text = "";
    }
Exemplo n.º 2
0
    public static IEnumerator StartServer(bool doLoad, string saveFileOverride, bool allowOutOfDateSaves)
    {
        float timeScale = UnityEngine.Time.timeScale;

        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = 0f;
        }
        RCon.Initialize();
        BaseEntity.Query.Server = new BaseEntity.Query.EntityTree(8096f);
        if ((bool)SingletonComponent <WorldSetup> .Instance)
        {
            yield return(SingletonComponent <WorldSetup> .Instance.StartCoroutine(SingletonComponent <WorldSetup> .Instance.InitCoroutine()));
        }
        if ((bool)SingletonComponent <DynamicNavMesh> .Instance && SingletonComponent <DynamicNavMesh> .Instance.enabled && !AiManager.nav_disable)
        {
            yield return(SingletonComponent <DynamicNavMesh> .Instance.StartCoroutine(SingletonComponent <DynamicNavMesh> .Instance.UpdateNavMeshAndWait()));
        }
        if ((bool)SingletonComponent <AiManager> .Instance && SingletonComponent <AiManager> .Instance.enabled)
        {
            SingletonComponent <AiManager> .Instance.Initialize();

            if (!AiManager.nav_disable && AI.npc_enable && TerrainMeta.Path != null)
            {
                foreach (MonumentInfo monument in TerrainMeta.Path.Monuments)
                {
                    if (monument.HasNavmesh)
                    {
                        yield return(monument.StartCoroutine(monument.GetMonumentNavMesh().UpdateNavMeshAndWait()));
                    }
                }
                if ((bool)TerrainMeta.Path && (bool)TerrainMeta.Path.DungeonRoot)
                {
                    DungeonNavmesh dungeonNavmesh = TerrainMeta.Path.DungeonRoot.AddComponent <DungeonNavmesh>();
                    dungeonNavmesh.NavMeshCollectGeometry = NavMeshCollectGeometry.PhysicsColliders;
                    dungeonNavmesh.LayerMask = 65537;
                    yield return(dungeonNavmesh.StartCoroutine(dungeonNavmesh.UpdateNavMeshAndWait()));
                }
                else
                {
                    Debug.LogError("Failed to find DungeonRoot, NOT generating Dungeon navmesh");
                }
            }
        }
        GameObject gameObject = GameManager.server.CreatePrefab("assets/bundled/prefabs/system/server.prefab");

        Object.DontDestroyOnLoad(gameObject);
        ServerMgr serverMgr = gameObject.GetComponent <ServerMgr>();

        serverMgr.Initialize(doLoad, saveFileOverride, allowOutOfDateSaves);
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityLinks();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntitySupports();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.InitializeEntityConditionals();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        SaveRestore.GetSaveCache();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        BaseGameMode.CreateGameMode();
        yield return(CoroutineEx.waitForSecondsRealtime(0.1f));

        serverMgr.OpenConnection();
        CompanionServer.Server.Initialize();
        using (BenchmarkTimer.New("Boombox.LoadStations"))
        {
            BoomBox.LoadStations();
        }
        if (ConVar.Time.pausewhileloading)
        {
            UnityEngine.Time.timeScale = timeScale;
        }
        WriteToLog("Server startup complete");
    }
 public void ChangeMode()
 {
     gameMode?.Deinit(this);
     gameMode = modetoChange;
     modetoChange?.Init(this);
 }
Exemplo n.º 4
0
        private void Initialize()
        {
            try {
                try {
                    Directory.CreateDirectory(Environment.CurrentDirectory.Replace('\\', '/') + "/UserData/Chroma");
                } catch (Exception e) {
                    ChromaLogger.Log("Error " + e.Message + " while trying to create Chroma directory", ChromaLogger.Level.WARNING);
                }

                ChromaLogger.Init();

                ChromaLogger.Log("************************************", ChromaLogger.Level.INFO);
                ChromaLogger.Log("Initializing Chroma [" + ChromaPlugin.Version.ToString() + "]", ChromaLogger.Level.INFO);
                ChromaLogger.Log("************************************", ChromaLogger.Level.INFO);

                //Used for getting gamemode data mostly
                try {
                    ChromaLogger.Log("Initializing Coordinators");
                    BaseGameMode.InitializeCoordinators();
                } catch (Exception e) {
                    ChromaLogger.Log("Error initializing coordinators", ChromaLogger.Level.ERROR);
                    throw e;
                }

                ChromaLogger.Log("Registering scenechange events");
                SceneManager.activeSceneChanged += SceneManagerOnActiveSceneChanged;
                SceneManager.sceneLoaded        += SceneManager_sceneLoaded;

                //Getting and starting all the extension plugins
                try {
                    ChromaLogger.Log("Checking for extensions.");
                    foreach (PluginLoader.PluginInfo pluginInfo in PluginManager.AllPlugins)
                    {
                        //We can't get IBeatSaberPlugin references

                        /*if (plugin is IChromaExtension chromaExtension) {
                         *  chromaExtension.ChromaApplicationStarted(this);
                         *  chromaExtensions.Add(chromaExtension);
                         * }*/
                    }
                } catch (Exception) {
                    ChromaLogger.Log("Error adding all Extension plugins!  Extension registration interrupted.", ChromaLogger.Level.ERROR);
                }

                //Harmony & extension Harmony patches
                ChromaLogger.Log("Patching with Harmony.");
                try {
                    coreHarmony.PatchAll(System.Reflection.Assembly.GetExecutingAssembly());
                    harmonyInstances.Add(coreHarmony);
                    foreach (IChromaExtension extension in chromaExtensions)
                    {
                        HarmonyInstance newPatch = extension.PatchHarmony();
                        if (newPatch != null)
                        {
                            harmonyInstances.Add(newPatch);
                        }
                    }
                } catch (Exception e) {
                    ChromaLogger.Log(e);
                    ChromaLogger.Log("This plugin requires Harmony.  Either you do not have it installed, or there was an error.", ChromaLogger.Level.ERROR);
                }

                ChromaLogger.Log("Creating AudioUtil");
                AudioUtil ab = AudioUtil.Instance;

                //Configuration Files
                try {
                    ChromaLogger.Log("Initializing Configuration");
                    ChromaConfig.Init();
                    ChromaConfig.LoadSettings(ChromaConfig.LoadSettingsType.INITIAL);
                } catch (Exception e) {
                    ChromaLogger.Log("Error loading Chroma configuration", ChromaLogger.Level.ERROR);
                    throw e;
                }

                ChromaLogger.Log("Refreshing Lights");
                ColourManager.RefreshLights();

                //Side panel
                try {
                    ChromaLogger.Log("Stealing Patch Notes Panel");
                    Greetings.RegisterChromaSideMenu();
                    SidePanelUtil.ReleaseInfoEnabledEvent += ReleaseInfoEnabled;
                } catch (Exception e) {
                    ChromaLogger.Log("Error handling UI side panel", ChromaLogger.Level.ERROR);
                    throw e;
                }
            } catch (Exception e) {
                ChromaLogger.Log("Failed to initialize ChromaPlugin!  Major error!", ChromaLogger.Level.ERROR);
                ChromaLogger.Log(e);
            }

            ChromaLogger.Log("Chroma finished initializing.  " + chromaExtensions.Count + " extensions found.", ChromaLogger.Level.INFO);

            try {
                SongCore.Collections.RegisterCapability("Chroma");
                SongCore.Collections.RegisterCapability("ChromaLite");
            } catch (Exception) {
                // This version of SongLoader doesn't support capabilities
            }
        }
Exemplo n.º 5
0
    public void OnGameModeChanged(BaseGameMode newGameMode)
    {
        bool toggle = ShouldBeVisible(newGameMode);

        SetToggle(toggle);
    }
Exemplo n.º 6
0
    public void UpdateCaptureAmount()
    {
        if (base.isClient)
        {
            return;
        }
        float        num            = captureFraction;
        BaseGameMode activeGameMode = BaseGameMode.GetActiveGameMode(true);

        if (activeGameMode == null)
        {
            return;
        }
        if (captureTrigger.entityContents == null)
        {
            SetFlag(Flags.Busy, false, false, false);
        }
        else
        {
            if (!activeGameMode.IsMatchActive())
            {
                return;
            }
            if (activeGameMode.IsTeamGame())
            {
                int[] array = new int[activeGameMode.GetNumTeams()];
                foreach (BaseEntity entityContent in captureTrigger.entityContents)
                {
                    if (!(entityContent == null) && !entityContent.isClient)
                    {
                        BasePlayer component = entityContent.GetComponent <BasePlayer>();
                        if (!(component == null) && component.IsAlive() && !component.IsNpc && component.gamemodeteam != -1)
                        {
                            array[component.gamemodeteam]++;
                        }
                    }
                }
                int num2 = 0;
                for (int i = 0; i < array.Length; i++)
                {
                    if (array[i] > 0)
                    {
                        num2++;
                    }
                }
                if (num2 < 2)
                {
                    int num3 = -1;
                    int num4 = 0;
                    for (int j = 0; j < array.Length; j++)
                    {
                        if (array[j] > num4)
                        {
                            num4 = array[j];
                            num3 = j;
                        }
                    }
                    if (captureTeam == -1 && captureFraction == 0f)
                    {
                        capturingTeam = num3;
                    }
                    if (captureFraction > 0f && num3 != captureTeam && num3 != capturingTeam)
                    {
                        captureFraction = Mathf.Clamp01(captureFraction - Time.deltaTime / timeToCapture);
                        if (captureFraction == 0f)
                        {
                            captureTeam = -1;
                        }
                    }
                    else if (captureTeam == -1 && captureFraction < 1f && capturingTeam == num3)
                    {
                        DoProgressEffect();
                        captureFraction = Mathf.Clamp01(captureFraction + Time.deltaTime / timeToCapture);
                        if (captureFraction == 1f)
                        {
                            DoCaptureEffect();
                            captureTeam = num3;
                        }
                    }
                }
                SetFlag(Flags.Busy, num2 > 1);
            }
            else
            {
                if (!capturingPlayer.IsValid(true) && !capturedPlayer.IsValid(true))
                {
                    captureFraction = 0f;
                }
                if (captureTrigger.entityContents.Count == 0)
                {
                    capturingPlayer.Set(null);
                }
                if (captureTrigger.entityContents.Count == 1)
                {
                    foreach (BaseEntity entityContent2 in captureTrigger.entityContents)
                    {
                        BasePlayer component2 = entityContent2.GetComponent <BasePlayer>();
                        if (component2 == null)
                        {
                            continue;
                        }
                        if (!capturedPlayer.IsValid(true) && captureFraction == 0f)
                        {
                            capturingPlayer.Set(component2);
                        }
                        if (captureFraction > 0f && component2 != capturedPlayer.Get(true) && component2 != capturingPlayer.Get(true))
                        {
                            captureFraction = Mathf.Clamp01(captureFraction - Time.deltaTime / timeToCapture);
                            if (captureFraction == 0f)
                            {
                                capturedPlayer.Set(null);
                            }
                        }
                        else if (!capturedPlayer.Get(true) && captureFraction < 1f && capturingPlayer.Get(true) == component2)
                        {
                            DoProgressEffect();
                            captureFraction = Mathf.Clamp01(captureFraction + Time.deltaTime / timeToCapture);
                            if (captureFraction == 1f)
                            {
                                DoCaptureEffect();
                                capturedPlayer.Set(component2);
                            }
                        }
                        break;
                    }
                }
                SetFlag(Flags.Busy, captureTrigger.entityContents.Count > 1);
            }
            if (num != captureFraction)
            {
                SendNetworkUpdate();
            }
        }
    }
Exemplo n.º 7
0
 // Start is called before the first frame update
 private void Awake()
 {
     Manager  = GameObject.FindObjectOfType <WorldManager>();
     GameMode = GameObject.FindObjectOfType <BaseGameMode>();
 }