Esempio n. 1
0
        public void Process()
        {
            using var log = Logger.LogBlock();

            while (Graph.TryGetNextStartNode(out var currentNode))
            {
                Logger.Log($"Start node selected: {currentNode.Name}");

                MouseSafetyMeasures.Instance.LastActionPosition = MouseSafetyMeasures.GetCursorCurrentPosition();

                List <SerializablePoint> actionPoints = new List <SerializablePoint>();

                do
                {
                    ProcessNode(currentNode, actionPoints.ToArray());

                    ConditionEdge?currentEdge = null;

                    while (Graph.TryGetNextEdge(currentNode, out currentEdge))
                    {
                        Logger.Log($"Next edge selected: {currentEdge.Name}");

                        if (ProcessEdge(currentEdge, actionPoints))
                        {
                            ReportBuilder.ReportBuilder.Commit(ReportMessageType.Success);

                            Graph.TryGetNextNode(currentEdge, ref currentNode);

                            Logger.Log($"Next node selected: {currentNode.Name}");

                            break;
                        }
                        else
                        {
                            ReportBuilder.ReportBuilder.Commit(ReportMessageType.Fail);
                        }
                    }

                    if (currentNode.IsNot(ActionNodeFlags.EndNode) && currentEdge is null)
                    {
                        throw new AutoFarmerException($"Can not move to the next node from {currentNode.Name}");
                    }
                }while (currentNode.IsNot(ActionNodeFlags.EndNode));

                ProcessNode(currentNode);

                Graph.ResetState();
            }
        }
Esempio n. 2
0
 public static void FromConfig()
 {
     Instance = JsonConvert.DeserializeObject <MouseSafetyMeasures>(File.ReadAllText(Config.Instance.MouseSafetyMeasuresConfigPath));
 }