示例#1
0
        //

        protected GameLevel(SkyCoreAPI plugin, string gameType, string gameId, String levelPath, GameLevelInfo gameLevelInfo, bool modifiable = false)
            : base(plugin.Server.LevelManager, gameId,
                   AnvilProviderFactory.GetLevelProvider(plugin.Server.LevelManager, levelPath, !modifiable, true, !modifiable),
                   plugin.Server.LevelManager.EntityManager, GameMode.Creative)
        {
            string levelName;

            {
                string[] split = levelPath.Split('\\');
                levelName = split[split.Length - 1];
            }

            LevelName = levelName;

            Plugin        = plugin;
            GameId        = gameId;
            GameType      = gameType;
            GameLevelInfo = gameLevelInfo;

            EnableBlockTicking = false;
            EnableChunkTicking = false;

            //SkyUtil.log($"Initializing world {gameId}");
            Initialize();

            SpawnPoint = GameLevelInfo.LobbyLocation;

            SetupWorldTime();

            if (!plugin.Server.LevelManager.Levels.Contains(this))
            {
                plugin.Server.LevelManager.Levels.Add(this);
            }

            InitializeTeamMap();

            CurrentState = GetInitialState();
            CurrentState.EnterState(this);

            GameLevelTickThread = new Thread(() =>
            {
                Thread.CurrentThread.IsBackground = true;

                GameLevelTick = new HighPrecisionTimer(500, PreGameTick, true);
            });
            GameLevelTickThread.Start();

            BlockBreak += HandleBlockBreak;
            BlockPlace += HandleBlockPlace;
        }
示例#2
0
	    protected GameController(SkyCoreAPI plugin, string gameName, string neatName, List<string> levelNames)
        {
            Plugin = plugin;
            
            GameName = neatName;
            RawName = gameName;
            
            foreach(var levelName in levelNames)
            {
                string fullLevelPath = $@"C:\Users\Administrator\Desktop\worlds\{gameName}\{levelName}";
	            if (!Directory.Exists(fullLevelPath))
	            {
					SkyUtil.log($"Unable to find world at ({fullLevelPath})");
				}
	            else
	            {
					LevelNames.Add(fullLevelPath);

		            SkyUtil.log($"Added world at ({fullLevelPath})");

					//Pre-load GameLevelInfo
		            GetGameLevelInfo(levelName);

					//Pre-cache the WorldProvider
		            AnvilProviderFactory.GetLevelProvider(plugin.Server.LevelManager, fullLevelPath);
	            }
            }

			if (LevelNames.Count == 0)
			{
				SkyUtil.log($"No Levels configured for {gameName}");
				return;
			}

			RedisGameIdKey = $"next_game_id_{GameName}";

	        ExternalGameHandler.RegisterInternalGame(RawName);

			GameTickThread = new Thread(() =>
	        {
		        Thread.CurrentThread.IsBackground = true;

		        GameTick = new HighPrecisionTimer(50, _CoreGameTick, true);
	        });
	        GameTickThread.Start();
		}