コード例 #1
0
        private static List <WowPoint> CreatePathPoints(ClassConfiguration classConfig)
        {
            List <WowPoint> pathPoints;
            string          pathText     = File.ReadAllText(classConfig.PathFilename);
            bool            thereAndBack = classConfig.PathThereAndBack;

            int step = classConfig.PathReduceSteps ? 2 : 1;

            var pathPoints2 = JsonConvert.DeserializeObject <List <WowPoint> >(pathText);

            pathPoints = new List <WowPoint>();
            for (int i = 0; i < pathPoints2.Count; i += step)
            {
                if (i < pathPoints2.Count)
                {
                    pathPoints.Add(pathPoints2[i]);
                }
            }

            if (thereAndBack)
            {
                var reversePoints = pathPoints.ToList();
                reversePoints.Reverse();
                pathPoints.AddRange(reversePoints);
            }

            pathPoints.Reverse();
            return(pathPoints);
        }
コード例 #2
0
        private void Initialize(ClassConfiguration config)
        {
            ConfigurableInput  = new ConfigurableInput(logger, wowProcess, config);
            ActionBarPopulator = new ActionBarPopulator(logger, wowProcess, ConfigurableInput, config, AddonReader);

            var blacklist = config.Mode != Mode.Grind ? new NoBlacklist() : (IBlacklist) new Blacklist(AddonReader.PlayerReader, config.NPCMaxLevels_Above, config.NPCMaxLevels_Below, config.Blacklist, logger);

            var actionFactory    = new GoalFactory(logger, AddonReader, ConfigurableInput, DataConfig, npcNameFinder, pather);
            var availableActions = actionFactory.CreateGoals(config, blacklist);

            RouteInfo = actionFactory.RouteInfo;

            this.GoapAgent = new GoapAgent(logger, wowProcess, ConfigurableInput, AddonReader.PlayerReader, availableActions, blacklist, config, AddonReader.BagReader);

            this.actionThread = new GoalThread(logger, ConfigurableInput, AddonReader.PlayerReader, GoapAgent);

            // hookup events between actions
            availableActions.ToList().ForEach(a =>
            {
                a.ActionEvent += this.actionThread.OnActionEvent;
                a.ActionEvent += GoapAgent.OnActionEvent;

                // tell other action about my actions
                availableActions.ToList().ForEach(b =>
                {
                    if (b != a)
                    {
                        a.ActionEvent += b.OnActionEvent;
                    }
                });
            });
        }
コード例 #3
0
 public ActionBarPopulator(ILogger logger, ClassConfiguration config, AddonReader addonReader, ExecGameCommand execGameCommand)
 {
     this.logger          = logger;
     this.config          = config;
     this.addonReader     = addonReader;
     this.execGameCommand = execGameCommand;
 }
コード例 #4
0
 public ActionBarPopulator(ILogger logger, WowProcess wowProcess, WowProcessInput wowProcessInput, ClassConfiguration config, AddonReader addonReader)
 {
     this.logger          = logger;
     this.wowProcess      = wowProcess;
     this.wowProcessInput = wowProcessInput;
     this.config          = config;
     this.addonReader     = addonReader;
 }
コード例 #5
0
 public MountHandler(ILogger logger, ConfigurableInput input, ClassConfiguration classConfig, Wait wait, PlayerReader playerReader, StopMoving stopMoving)
 {
     this.logger       = logger;
     this.classConfig  = classConfig;
     this.input        = input;
     this.wait         = wait;
     this.playerReader = playerReader;
     this.stopMoving   = stopMoving;
 }
コード例 #6
0
        public HashSet <GoapGoal> CreateGoals(ClassConfiguration classConfig, IBlacklist blacklist)
        {
            var availableActions = new HashSet <GoapGoal>();

            List <WowPoint> pathPoints, spiritPath;

            GetPaths(out pathPoints, out spiritPath, classConfig);

            var playerDirection = new PlayerDirection(logger, input, addonReader.PlayerReader);
            var stopMoving      = new StopMoving(input, addonReader.PlayerReader);

            var castingHandler = new CastingHandler(logger, input, addonReader.PlayerReader, classConfig, playerDirection, npcNameFinder);

            var stuckDetector      = new StuckDetector(logger, input, addonReader.PlayerReader, playerDirection, stopMoving);
            var followRouteAction  = new FollowRouteGoal(logger, input, addonReader.PlayerReader, playerDirection, pathPoints, stopMoving, npcNameFinder, blacklist, stuckDetector, classConfig, pather);
            var walkToCorpseAction = new WalkToCorpseGoal(logger, input, addonReader.PlayerReader, playerDirection, spiritPath, pathPoints, stopMoving, stuckDetector, pather);

            availableActions.Clear();

            if (classConfig.Mode == Mode.CorpseRun)
            {
                availableActions.Add(new WaitGoal(logger));
                availableActions.Add(new CorpseRunGoal(addonReader.PlayerReader, input, playerDirection, spiritPath, stopMoving, logger, stuckDetector));
            }
            else if (classConfig.Mode == Mode.AttendedGather)
            {
                availableActions.Add(followRouteAction);
                availableActions.Add(new CorpseRunGoal(addonReader.PlayerReader, input, playerDirection, spiritPath, stopMoving, logger, stuckDetector));
            }
            else
            {
                if (classConfig.Mode == Mode.AttendedGrind)
                {
                    availableActions.Add(new WaitGoal(logger));
                }
                else
                {
                    availableActions.Add(followRouteAction);
                    availableActions.Add(walkToCorpseAction);
                }
                availableActions.Add(new ApproachTargetGoal(logger, input, addonReader.PlayerReader, stopMoving, stuckDetector));

                if (classConfig.WrongZone.ZoneId > 0)
                {
                    availableActions.Add(new WrongZoneGoal(addonReader.PlayerReader, input, playerDirection, logger, stuckDetector, classConfig));
                }

                if (classConfig.Parallel.Sequence.Count > 0)
                {
                    availableActions.Add(new ParallelGoal(logger, input, addonReader.PlayerReader, stopMoving, classConfig.Parallel.Sequence, castingHandler));
                }

                if (classConfig.Loot)
                {
                    var lootAction = new LootGoal(logger, input, addonReader.PlayerReader, addonReader.BagReader, stopMoving, classConfig, npcNameFinder);
                    lootAction.AddPreconditions();
                    availableActions.Add(lootAction);

                    if (classConfig.Skin)
                    {
                        availableActions.Add(new SkinningGoal(logger, input, addonReader.PlayerReader, addonReader.BagReader, addonReader.equipmentReader, stopMoving, classConfig, npcNameFinder));
                    }
                }

                try
                {
                    var genericCombat = new CombatGoal(logger, input, addonReader.PlayerReader, stopMoving, classConfig, castingHandler);
                    availableActions.Add(genericCombat);
                    availableActions.Add(new PullTargetGoal(logger, input, addonReader.PlayerReader, npcNameFinder, stopMoving, castingHandler, stuckDetector, classConfig));

                    availableActions.Add(new CreatureKilledGoal(logger, addonReader.PlayerReader, classConfig));
                    availableActions.Add(new ConsumeCorpse(logger, addonReader.PlayerReader));

                    foreach (var item in classConfig.Adhoc.Sequence)
                    {
                        availableActions.Add(new AdhocGoal(logger, input, item, addonReader.PlayerReader, stopMoving, castingHandler));
                    }
                }
                catch (Exception ex)
                {
                    logger.LogError(ex.ToString());
                }


                foreach (var item in classConfig.NPC.Sequence)
                {
                    availableActions.Add(new AdhocNPCGoal(logger, input, addonReader.PlayerReader, playerDirection, stopMoving, npcNameFinder, stuckDetector, classConfig, pather, item, blacklist));
                    item.Path.AddRange(ReadPath(item.Name, item.PathFilename));
                }

                var pathProviders = availableActions.Where(a => a is IRouteProvider)
                                    .Cast <IRouteProvider>()
                                    .ToList();

                this.RouteInfo = new RouteInfo(pathPoints, spiritPath, pathProviders, addonReader.PlayerReader);

                this.pather.DrawLines(new List <LineArgs>()
                {
                    new LineArgs  {
                        Spots = pathPoints, Name = "grindpath", Colour = 2, MapId = addonReader.PlayerReader.ZoneId
                    },
                    new LineArgs {
                        Spots = spiritPath, Name = "spirithealer", Colour = 3, MapId = addonReader.PlayerReader.ZoneId
                    }
                });
            }

            return(availableActions);
        }
コード例 #7
0
        private static List <WowPoint> CreateSpiritPathPoints(List <WowPoint> pathPoints, ClassConfiguration classConfig)
        {
            List <WowPoint> spiritPath;

            if (string.IsNullOrEmpty(classConfig.SpiritPathFilename))
            {
                spiritPath = new List <WowPoint> {
                    pathPoints.First()
                };
            }
            else
            {
                string spiritText = File.ReadAllText(classConfig.SpiritPathFilename);
                spiritPath = JsonConvert.DeserializeObject <List <WowPoint> >(spiritText);
            }

            return(spiritPath);
        }
コード例 #8
0
        private void GetPaths(out List <WowPoint> pathPoints, out List <WowPoint> spiritPath, ClassConfiguration classConfig)
        {
            classConfig.PathFilename       = FixPathFilename(classConfig.PathFilename);
            classConfig.SpiritPathFilename = FixPathFilename(classConfig.SpiritPathFilename);

            pathPoints = CreatePathPoints(classConfig);
            spiritPath = CreateSpiritPathPoints(pathPoints, classConfig);
        }
コード例 #9
0
 public void OverrideClassConfig(ClassConfiguration classConfiguration)
 {
     this.ClassConfig = classConfiguration;
     Initialize(this.ClassConfig);
 }
コード例 #10
0
 public ConfigurableInput(ILogger logger, WowProcess wowProcess, ClassConfiguration classConfiguration) : base(logger, wowProcess)
 {
     this.logger      = logger;
     this.classConfig = classConfiguration;
 }
コード例 #11
0
 public ConfigurableInput(ILogger logger, WowProcess wowProcess, ClassConfiguration classConfig) : base(logger, wowProcess)
 {
     ClassConfig = classConfig;
 }