Beispiel #1
0
        public void OnPlayerSpawned(IPlayerSpawnedEvent e)
        {
            _logger.LogInformation("Player {player} > spawned", e.PlayerControl.PlayerInfo.PlayerName);

            // Need to make a local copy because it might be possible that
            // the event gets changed after being handled.
            var clientPlayer  = e.ClientPlayer;
            var playerControl = e.PlayerControl;

            Task.Run(async() =>
            {
                _logger.LogDebug("Starting player task");

                // Give the player time to load.
                await Task.Delay(TimeSpan.FromSeconds(3));

                while (clientPlayer.Client.Connection != null && clientPlayer.Client.Connection.IsConnected)
                {
                    // Modify player properties.
                    await playerControl.SetColorAsync((ColorType)_random.Next(1, 9));
                    await playerControl.SetHatAsync((HatType)_random.Next(1, 9));
                    await playerControl.SetSkinAsync((SkinType)_random.Next(1, 9));
                    await playerControl.SetPetAsync((PetType)_random.Next(1, 9));

                    await Task.Delay(TimeSpan.FromMilliseconds(5000));
                }

                _logger.LogDebug("Stopping player task");
            });
        }
Beispiel #2
0
        public void OnPlayerSpawn(IPlayerSpawnedEvent e)
        {
            if (!_roleManager.IsActive() && !_gameModeManager.IsActive())
            {
                return;
            }

            Task.Factory.StartNew(() =>
            {
                Task.Delay(1500).Wait();
                var active   = "<align=\"center\"><size=150%><#0000FF>Roles & GameModes:<#000000><size=100%>";
                var commands = "<#000000><align=\"center\"><b>Commands:</b>";

                if (_gameModeManager.IsActive())
                {
                    active   += "\n" + _gameModeManager.GetStatus(e.Game);
                    commands += "\n" + _gameModeManager.GetCommands();
                }

                if (_roleManager.IsActive())
                {
                    active   += "\n\n" + _roleManager.GetStatus(e.Game);
                    commands += "\n" + _roleManager.GetCommands();
                }


                e.PlayerControl.SendChatToPlayerAsync(active);
                e.PlayerControl.SendChatToPlayerAsync(commands);
            });
        }
        public void OnPlayerSpawned(IPlayerSpawnedEvent e)
        {
            _logger.LogDebug(e.PlayerControl.PlayerInfo.PlayerName + " spawned");

            // Need to make a local copy because it might be possible that
            // the event gets changed after being handled.
            var clientPlayer  = e.ClientPlayer;
            var playerControl = e.PlayerControl;

            /*
             * Task.Run(async () =>
             * {
             *  Console.WriteLine("Starting player task.");
             *
             *  // Give the player time to load.
             *  await Task.Delay(TimeSpan.FromSeconds(3));
             *
             *  while (clientPlayer.Client.Connection != null &&
             *         clientPlayer.Client.Connection.IsConnected)
             *  {
             *      // Modify player properties.
             *      await playerControl.SetColorAsync((byte) Random.Next(1, 9));
             *      await playerControl.SetHatAsync((uint) Random.Next(1, 9));
             *      await playerControl.SetSkinAsync((uint) Random.Next(1, 9));
             *      await playerControl.SetPetAsync((uint) Random.Next(1, 9));
             *
             *      await Task.Delay(TimeSpan.FromMilliseconds(5000));
             *  }
             *
             *  _logger.LogDebug("Stopping player task.");
             * });
             */
        }
Beispiel #4
0
 public void OnPlayerSpawned(IPlayerSpawnedEvent e)
 {
     if (JesterGames[e.Game.Code].GameEnded && JesterGames[e.Game.Code].JesterInGame)
     {
         Task.Run(async() => await JesterAnnouncement(e).ConfigureAwait(false));
     }
 }
        public async ValueTask OnPlayerSpawned(IPlayerSpawnedEvent e)
        {
            var clientInfo = e.ClientPlayer.Client.GetReactor();

            if (clientInfo != null && clientInfo.Mods.Any(x => x.Id == "gg.reactor.Example"))
            {
                await _rpcManager.Get <ExampleRpc>().SendAsync(e.PlayerControl, "SendTo: from server to spawned client", e.ClientPlayer.Client);
            }
        }
Beispiel #6
0
 public async void OnLobbyCreate(IPlayerSpawnedEvent e)
 {
     if (e.ClientPlayer.IsHost)
     {
         await Task.Delay(1000);
         await SendMessage(e.PlayerControl, "Welcome to the server!");
         await SendMessage(e.PlayerControl, "Type /help for a list of all the commands!");
     }
 }
 public async void OnLobbyCreate(IPlayerSpawnedEvent e)
 {
     if (e.ClientPlayer.IsHost)
     {
         await Task.Delay(1000);
         await SendMessage(e.PlayerControl, "Welcome to the server!");
         await SendMessage(e.PlayerControl, "This server is powered by All of Us Bot, an Impostor plugin designed to be used with All of Us Mod, a 100 Player Mod for Among Us!");
         await SendMessage(e.PlayerControl, "Type /help for a list of all the commands!");
     }
 }
Beispiel #8
0
 /// <summary>
 /// Call this whenever a player spawns. It will handle any permanent bans.
 /// </summary>
 /// <param name="evt"></param>
 public void HandleSpawn(IPlayerSpawnedEvent evt)
 {
     lock (PermanentBans)
     {
         foreach (var ban in PermanentBans)
         {
             if (ban.Target.Equals(evt.ClientPlayer.Client.Connection.EndPoint.Address.ToString()))
             {
                 evt.ClientPlayer.BanAsync();
             }
         }
     }
 }
Beispiel #9
0
 private async Task JesterAnnouncement(IPlayerSpawnedEvent e)
 {
     if (JesterGames[e.Game.Code].Jesterwin)
     {
         await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false);
         await ServerSendChatToPlayerAsync($"{JesterGames[e.Game.Code].Jestername} was Jester and won by getting ejected!", e.PlayerControl).ConfigureAwait(false);
     }
     else
     {
         await Task.Delay(TimeSpan.FromSeconds(5)).ConfigureAwait(false);
         await ServerSendChatToPlayerAsync($"{JesterGames[e.Game.Code].Jestername} was Jester, but didn't get voted out.", e.PlayerControl).ConfigureAwait(false);
     }
 }
Beispiel #10
0
        public void OnPlayerSpawned(IPlayerSpawnedEvent e)
        {
            GamesManager.OnPlayerChanged(e.Game.Code, e.PlayerControl.PlayerInfo, PlayerAction.Joined);
            _players.TryAdd(e.ClientPlayer.Client.Id, new Player(e.ClientPlayer, this));

            if (BotConnected)
            {
                _ = ChatManager.SendServerMessage(e.PlayerControl, $"Hi, {e.PlayerControl.PlayerInfo.PlayerName}, " +
                                                  $"we're play by [add8e6ff]Discord [ffffffff]with [008080ff]AutometeUs!");
            }

            CheckUpdate(e);
        }
Beispiel #11
0
        public void OnPlayerSpawned(IPlayerSpawnedEvent e)
        {
            Game game = AutomuteUsPlugin.gamesManager.GetGame(e);

            if (game == null)
            {
                _ = ChatManager.SendServerMessage(e.PlayerControl, "We play by [add8e6ff]Discord [000000ff]with [008080ff]AutometeUs");
                if (e.ClientPlayer.IsHost)
                {
                    _ = ChatManager.SendServerMessage(e.PlayerControl, "Type [ffa500ff]/discord [000000ff]command to create a new game on the Discord server channel...");
                }

                // ...
            }
            else
            {
                game.OnPlayerSpawned(e);
            }
        }
Beispiel #12
0
 public void OnPlayerSpawned(IPlayerSpawnedEvent evt)
 {
     OnPlayerSpawnedFirst?.Invoke(evt);
 }
Beispiel #13
0
 public void OnPlayerSpawned(IPlayerSpawnedEvent e)
 {
     _automuteService.OnPlayerSpawned(e.ClientPlayer);
 }
Beispiel #14
0
 public void OnPlayerSpawned(IPlayerSpawnedEvent evt)
 {
     Interlocked.Increment(ref OnPlayerSpawnedCount);
 }
 public void OnPlayerSpawned(IPlayerSpawnedEvent evt) => PlayerSpawned?.Invoke(evt);