Exemplo n.º 1
0
 public override void Start()
 {
     _thread = new MemoryThread("Sekiro", Defs.PointerByName("LastCommutedIdol"), 4, EventName());
     _thread.ValueChanged += (sender, args) => {
         try {
             var idol = Defs.IdolById(BitConverter.ToInt32(args.Bytes, 0));
             if (idol == null)
             {
                 return;
             }
             SetValue(idol);
         } catch {
             // Ignored
         }
     };
     _thread.Start();
 }
Exemplo n.º 2
0
        private void Init()
        {
            Diag.WriteLine("Initializing");
            SetStatus("Initializing", Color.OrangeRed);

            var remoteProc = RemoteProc.Instance();

            if (remoteProc == null)
            {
                MetroMessageBox.Show(this, "Sekiro should be running but was not found..", "Error",
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            foreach (var flag in Defs.Flags.FastReverse())
            {
                flag.RenderFlag(this);
            }

            GameState = new GameState();
            GameState.Subscribe((sender, e) => {
                var value = e.Value;
                if (value.GetType() != typeof(byte))
                {
                    return;
                }
                var b = (byte)value;

                UpdateCtrl(lblLoading, () => {
                    if (b == 1)
                    {
                        lblLoading.Text = "Loading: no";
                    }
                    else if (b == 0)
                    {
                        lblLoading.Text = "Loading: yes";
                    }
                    else
                    {
                        lblLoading.Text = "Loading: unknown";
                    }
                });
            });
            GameState.Start();

            PlayerPos = new PlayerPos();
            PlayerPos.Subscribe((sender, e) => {
                var pos = (Vector3)e.Value;
                UpdateCtrl(lblPosX, () => lblPosX.Text = $"X: {pos.X}");
                UpdateCtrl(lblPosY, () => lblPosY.Text = $"Y: {pos.Y}");
                UpdateCtrl(lblPosZ, () => lblPosZ.Text = $"Z: {pos.Z}");
            });
            PlayerPos.Start();

            IngameTime = new IngameTime();
            IngameTime.Subscribe((sender, e) => {
                UpdateCtrl(lblIgt, () => lblIgt.Text = $"IGT: {(string)e.Value}");
            });
            IngameTime.Start();

            PlayerStats = new PlayerStats();
            PlayerStats.Subscribe((sender, e) => {
                var player = (Player)e.Value;
                UpdateCtrl(lblHealth, () => lblHealth.Text   = $"Health: {player.CurrentHealth}/{player.MaximumHealth}");
                UpdateCtrl(lblPosture, () => lblPosture.Text = $"Posture: {player.CurrentPosture}/{player.MaximumPosture}");
            });
            PlayerStats.Start();

            LastIdol = new LastIdol();
            LastIdol.Subscribe((sender, e) => {
                var idola = (Idol)e.Value;
                UpdateCtrl(cboxLastIdol, () => cboxLastIdol.SelectedItem = idola.Name);
            });
            LastIdol.Start();

            var lastIdol = remoteProc.Read <int>(Defs.PointerByName("LastCommutedIdol").GetAddress(remoteProc));
            var idol     = Defs.IdolById(lastIdol);

            if (idol == null)
            {
                Diag.WriteLine($"Null Idol? {lastIdol}");
            }
            else
            {
                UpdateCtrl(cboxLastIdol, () => {
                    cboxLastIdol.SelectedItem = idol.Name;
                });
            }

            SetStatus("Ready", Color.LimeGreen);
            Enable();
        }