2
Good morning, can anyone find the mistake I’m making by instantiating? I get that message back:
Method error: Render : System.Nullreferenceexception: Reference to object not defined for an object instance. in Autophaserun.Enabler.Enabled() in Autophaserun.AutoPhaseRun.Render() in Poehud.Plugins.Baseplugin. _Render()
Class:
using PoeHUD.Poe.Components;
using System;
using PoeHUD.Plugins;
using System.Windows.Forms;
using PoeHUD.Controllers;
public bool Enabled() {
        if (GameController.Area.CurrentArea.IsHideout 
            || GameController.Area.CurrentArea.IsTown 
            || !GameController.Player.IsAlive 
            || !Settings.Enable 
            || GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Life>().Buffs.Exists(b => b.Name == "grace_period")
            || Control.IsKeyLocked(Keys.CapsLock) == false)
            return false;
        if (GameController.Game.IngameState.IngameUi.InventoryPanel.IsVisible
            || GameController.Game.IngameState.IngameUi.OpenLeftPanel.IsVisible
            || GameController.Game.IngameState.IngameUi.AtlasPanel.IsVisible
            || GameController.Game.IngameState.IngameUi.OpenRightPanel.IsVisible
            || GameController.Game.IngameState.IngameUi.SyndicatePanel.IsVisible
            || GameController.Game.IngameState.IngameUi.IncursionWindow.IsVisible
            || GameController.Game.IngameState.IngameUi.TreePanel.IsVisible
            || GameController.Game.IngameState.IngameUi.HiddenSkillBar.IsVisible
            || GameController.Game.IngameState.UIRoot.GetChildFromIndices(1, 111).ChildCount > 0)
            return false;
        else
            return true;
    }
Main:
using PoeHUD.Poe.Components;
using System;
using PoeHUD.Plugins;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using System.Threading;
using PoeHUD.Controllers;
public class AutoPhaseRun : BaseSettingsPlugin<AutoPhaseRunSettings>
    {
        private DateTime lasttime = new DateTime();
        Enabler enabler = new Enabler();
        public override void Render()
        {
            try
            {
                bool teste = enabler.Enabled();
                if (teste == false)
                    return;
                if ((DateTime.Now - lasttime).TotalSeconds > Settings.delay.Value)
                {
                    var buffs = GameController.Game.IngameState.Data.LocalPlayer.GetComponent<Life>().Buffs;
                    if (!buffs.Exists(b => b.Name == "new_phase_run"))
                    {
                        Keyboard.KeyPress(Settings.pressedKey.Value);
                        lasttime = DateTime.Now;
                    }
                }
            }
            catch (Exception e)
            {
                LogMessage(e.Message, 3);
                LogMessage(e.Source, 3);
                throw;
            }
        }
    }
Could include the usings?
– MauroAlmeida
See if any hint in this answer helps you: https://answall.com/a/369628/35358
– George Wurthmann
Create a break-point in the first
ifwithin the methodbool Enabled()(guess is a method whose class has been omitted) and pass the mouse pointer for each instance compared within the twoifs, or create a Quick watch for all identifiers, surely some is null.– Augusto Vasques