Beispiel #1
0
        private Task Game_MeetingEnded(AmongUsGame sender, MeetingEndAsyncEventArgs e)
        {
            if (this.GameManager.Guild == 0ul)
            {
                return(Task.CompletedTask);
            }

            _ = Task.Delay(TimeSpan.FromSeconds(e.ExileDuration))
                .ContinueWith(this.Game_MeetingEnded_Continuation);

            return(Task.CompletedTask);
        }
Beispiel #2
0
        private async Task Game_PlayerLeft(AmongUsGame sender, PlayerAsyncEventArgs e)
        {
            this.GameManager.RemovePlayer(e.Player.Name);

            var chn = this.GameManager.TextChannel;

            if (chn == 0ul)
            {
                return;
            }

            await this.DiscordBot.SendMessageAsync(chn, "Game ended");
        }
Beispiel #3
0
        private async Task Game_PlayerJoined(AmongUsGame sender, PlayerAsyncEventArgs e)
        {
            this.GameManager.AddPlayer(e.Player.Name);

            var chn = this.GameManager.TextChannel;

            if (chn == 0ul)
            {
                return;
            }

            await this.DiscordBot.SendMessageAsync(chn, $"New player: {e.Player.Name}");
        }
Beispiel #4
0
        private async Task Game_GameStarted(AmongUsGame sender, GameStartAsyncEventArgs e)
        {
            if (this.GameManager.VoiceChannel != 0ul)
            {
                await this.DiscordBot.MuteAllAsync(this.GameManager.VoiceChannel);
            }

            var chn = this.GameManager.TextChannel;

            if (chn == 0ul)
            {
                return;
            }

            await this.DiscordBot.SendMessageAsync(chn, $"Game started, map: {e.Map}");
        }
Beispiel #5
0
        private async Task Game_GameEnded(AmongUsGame sender, GameEndAsyncEventArgs e)
        {
            if (this.GameManager.VoiceChannel != 0ul)
            {
                await this.DiscordBot.UnmuteAllAsync(this.GameManager.VoiceChannel);
            }

            var chn = this.GameManager.TextChannel;

            if (chn == 0ul)
            {
                return;
            }

            await this.DiscordBot.SendMessageAsync(chn, "Game ended");
        }
        public ProbeHostedService(
            ILoggerFactory loggerFactory,
            DiscoveryClient discovery,
            AmongUsGame game,
            ProbeCommArray comms)
        {
            this.Logger    = loggerFactory.CreateLogger <ProbeHostedService>();
            this.Discovery = discovery;
            this.Game      = game;
            this.Comms     = comms;

            this.Game.GameStarted    += this.Game_GameStarted;
            this.Game.GameEnded      += this.Game_GameEnded;
            this.Game.PlayerJoined   += this.Game_PlayerJoined;
            this.Game.PlayerLeft     += this.Game_PlayerLeft;
            this.Game.PlayerDied     += this.Game_PlayerDied;
            this.Game.MeetingStarted += this.Game_MeetingStarted;
            this.Game.MeetingEnded   += this.Game_MeetingEnded;
        }
Beispiel #7
0
        private async Task Game_MeetingStarted(AmongUsGame sender, MeetingStartAsyncEventArgs e)
        {
            if (this.GameManager.VoiceChannel != 0ul)
            {
                var unmute = this.GameManager.GetUnmutables();
                var undeaf = this.GameManager.GetUndeafables();

                await this.DiscordBot.UnmuteAsync(this.GameManager.Guild, unmute);

                await this.DiscordBot.UndeafenAsync(this.GameManager.Guild, undeaf);
            }

            var chn = this.GameManager.TextChannel;

            if (chn == 0ul)
            {
                return;
            }

            await this.DiscordBot.SendMessageAsync(chn, "Meeting started");
        }
Beispiel #8
0
        public AmongUsDirectorHostedService(
            DiscordBotService discordBot,
            AmongUsGame game,
            GameManagerService gameManager,
            DiscoveryServer discovery,
            MothershipCommArray comms,
            RedisClientService redis)
        {
            this.DiscordBot  = discordBot;
            this.Game        = game;
            this.GameManager = gameManager;
            this.Discovery   = discovery;
            this.Comms       = comms;
            this.Redis       = redis;

            this.Game.GameStarted    += this.Game_GameStarted;
            this.Game.GameEnded      += this.Game_GameEnded;
            this.Game.PlayerJoined   += this.Game_PlayerJoined;
            this.Game.PlayerLeft     += this.Game_PlayerLeft;
            this.Game.PlayerDied     += this.Game_PlayerDied;
            this.Game.MeetingStarted += this.Game_MeetingStarted;
            this.Game.MeetingEnded   += this.Game_MeetingEnded;
        }
 private async Task Game_MeetingStarted(AmongUsGame sender, MeetingStartAsyncEventArgs e)
 => await this.Comms.SendEventAsync(new ProbeEvent(ProbeEventType.MeetingStart, ProbeMeetingStartEventPayload.FromEventArgs(e)));
 private async Task Game_PlayerDied(AmongUsGame sender, PlayerAsyncEventArgs e)
 => await this.Comms.SendEventAsync(new ProbeEvent(ProbeEventType.PlayerDeath, ProbePlayerEventPayload.FromEventArgs(e)));
 private async Task Game_GameEnded(AmongUsGame sender, GameEndAsyncEventArgs e)
 => await this.Comms.SendEventAsync(new ProbeEvent(ProbeEventType.GameEnd, ProbeGameEndEventPayload.FromEventArgs(e)));
Beispiel #12
0
 private Task Game_PlayerDied(AmongUsGame sender, PlayerAsyncEventArgs e)
 {
     this.GameManager.MarkDead(e.Player.Name);
     return(Task.CompletedTask);
 }