예제 #1
0
        public async Task AutoFollow()
        {
            var activeClients = new ActiveClients(Path.GetFileNameWithoutExtension(_config.Process));
            var leader        = activeClients.GetClient(_config.Leader);
            var distance      = _config.Distance;
            var followers     = activeClients.Clients.Where(client =>
                                                            !string.Equals(leader.Self.Name, client.Self.Name, StringComparison.OrdinalIgnoreCase))
                                .ToArray();

            Log.Information($"Following {leader.Self.Name} at a distance of no more than {distance} space(s).");

            while (_isRunning.Value)
            {
                try
                {
                    if (_isPaused.Value)
                    {
                        continue;
                    }

                    foreach (var follower in followers)
                    {
                        switch (follower.Self.BasePath)
                        {
                        case TkClient.BasePath.Mage:
                            await((MageClient)follower).Commands.Movement.Follow(leader, distance);
                            break;

                        case TkClient.BasePath.Poet:
                            await((PoetClient)follower).Commands.Movement.Follow(leader, distance);
                            break;

                        case TkClient.BasePath.Rogue:
                            await((RogueClient)follower).Commands.Movement.Follow(leader, distance);
                            break;

                        case TkClient.BasePath.Warrior:
                            await((WarriorClient)follower).Commands.Movement.Follow(leader, distance);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    TkTrainerFactory.Terminate(ex);
                }
            }
        }