Ejemplo n.º 1
0
        private static void StaminaDisplayLoop(PlayerStatusReader reader, PrismatikWriter writer)
        {
            writer.Connect();

            double?prevStamina = null;
            double?prevHP      = null;

            try
            {
                while (true)
                {
                    var stamina = reader.ReadStamina();
                    var hp      = reader.ReadHP();
                    if (stamina == null || hp == null)
                    {
                        writer.Unlock();
                        prevHP = prevStamina = null;
                        continue;
                    }

                    writer.Lock();
                    if (ShouldUpdate(ref prevStamina, ref prevHP, stamina, hp))
                    {
                        writer.DisplayPlayerStatus(stamina.Ratio, hp.Ratio);
                    }
                }
            }
            catch (ReadProcessException ex)
            {
                Console.WriteLine(ex.Message);
            }
            writer.Unlock();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Darksouls3 player status display by COB\n" +
                              "Based on CE table by \"The Grand Archives\"\n\n" +
                              "What does it do?\n" +
                              "It reads HP and SP from DarksoulsIII process and displays it in Ambilight using Prismatik\n\n" +
                              "Visit : https://github.com/cobrce/DS3PlayerStatusDisplay\n\n" +
                              "To update configuration use the following commande line (or modify config.json):\n" +
                              "   --IP <IP>\n" +
                              "   --PORT <PORT>\n" +
                              "   --LEDS <NumberOfLeds>\n" +
                              "   --REVERSE <1|0>\n" +
                              "-----------------------------------------\n");

            //args = new string[] { "--IP", "192.168.1.10", "--PORT", "2020", "--LEDS", "120", "--OFFSET", "-40", "--REVERSE", "0" };
            if (args.Length > 0)
            {
                Configure(args);
            }

            PrintConfig();

            while (true)
            {
                Console.WriteLine("Waiting for process");
                Process process = null;
                while (process == null)
                {
                    Thread.Sleep(200);
                    process = SearchForProces();
                }

                Console.WriteLine($"Working on process with ID : {process.Id}");
                var reader = new PlayerStatusReader(process);
                var writer = new PrismatikWriter(config.Ip, config.Port, config.NumberOfLeds, config.Offset, config.Reverse);
                StaminaDisplayLoop(reader, writer);
            }
        }