Пример #1
0
 public static void SetActiveGameMode(BaseGameMode newActive, bool serverside)
 {
     if ((bool)newActive)
     {
         newActive.InitScores();
     }
     if (BaseGameMode.GameModeChanged != null)
     {
         BaseGameMode.GameModeChanged(newActive);
     }
     if (serverside)
     {
         svActiveGameMode = newActive;
     }
 }
Пример #2
0
    public static void CreateGameMode(string overrideMode = "")
    {
        BaseGameMode activeGameMode = GetActiveGameMode(true);

        if ((bool)activeGameMode)
        {
            activeGameMode.ShutdownGame();
            activeGameMode.Kill();
            SetActiveGameMode(null, true);
        }
        string text = Server.gamemode;

        Debug.Log("Gamemode Convar :" + text);
        if (!string.IsNullOrEmpty(overrideMode))
        {
            text = overrideMode;
        }
        if (string.IsNullOrEmpty(text))
        {
            Debug.Log("No Gamemode.");
            if (BaseGameMode.GameModeChanged != null)
            {
                BaseGameMode.GameModeChanged(null);
            }
        }
        else
        {
            BaseEntity baseEntity = GameManager.server.CreateEntity("assets/prefabs/gamemodes/" + text + ".prefab", Vector3.zero, Quaternion.identity);
            if ((bool)baseEntity)
            {
                baseEntity.Spawn();
            }
            else
            {
                Debug.Log("Failed to create gamemode : " + text);
            }
        }
    }