Exemplo n.º 1
0
    private static void Main()
    {
        try
        {
            AutoUpdater.HttpUserAgent         = "AutoUpdater";
            AutoUpdater.ParseUpdateInfoEvent += OnParseUpdateInfo;
            AutoUpdater.Start("https://api.github.com/repos/LelouBil/AmongUsMumbleLink/releases/latest");
            Console.WriteLine("Starting");
            AppDomain.CurrentDomain.UnhandledException +=
                CurrentDomain_UnhandledException;

            // Cheat Init
            Console.WriteLine("try init cheese");
            if (Cheese.Init())
            {
                Console.WriteLine("Initialized cheese");
                // Update Player Data When Every Game
                Cheese.ObserveShipStatus((shipStat) =>
                {
                    try
                    {
                        ShipStatus status = Cheese.GetShipStatus();

                        if (status.OwnerId == 0 && !_saidWait)
                        {
                            foreach (var player in _playerDataList)
                            {
                                player.StopObserveState();
                            }
                            Console.WriteLine("Not in game, waiting....");
                            _x              = 0;
                            _y              = 0;
                            _z              = 0;
                            _localPlayer    = null;
                            _playerDataList = new List <PlayerData>();
                            _saidWait       = true;
                            return;
                        }

                        if (status.OwnerId != 0 && _saidWait)
                        {
                            _saidWait = false;
                        }

                        _playerDataList = Cheese.GetAllPlayers();

                        foreach (var player in _playerDataList)
                        {
                            if (player.IsLocalPlayer)
                            {
                                player.StartObserveState();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (!_saidWait)
                        {
                            foreach (var player in _playerDataList)
                            {
                                player.StopObserveState();
                            }
                            Console.WriteLine("Not in game, waiting....");
                            _localPlayer = null;
                            _saidWait    = true;
                            _x           = 0;
                            _y           = 0;
                            _z           = 0;
                        }

                        return;
                    }
                });
                Console.WriteLine("Starting Thread");
                CancellationTokenSource cts = new CancellationTokenSource();
                Task.Factory.StartNew(
                    UpdateCheat, cts.Token).Wait(cts.Token);
            }
            else
            {
                Console.WriteLine("Failed init cheese, game is not running or app is not running as admin");
            }
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
        Console.WriteLine("Press any key to stop...");
        Console.ReadKey();
    }