private void Initialize(ClassConfiguration config) { ConfigurableInput = new ConfigurableInput(logger, wowProcess, config); ActionBarPopulator = new ActionBarPopulator(logger, config, AddonReader, ExecGameCommand); var blacklist = config.Mode != Mode.Grind ? new NoBlacklist() : (IBlacklist) new Blacklist(logger, AddonReader, config.NPCMaxLevels_Above, config.NPCMaxLevels_Below, config.CheckTargetGivesExp, config.Blacklist); var goapAgentState = new GoapAgentState(); var actionFactory = new GoalFactory(logger, AddonReader, ConfigurableInput, DataConfig, npcNameFinder, npcNameTargeting, pather, ExecGameCommand); var availableActions = actionFactory.CreateGoals(config, blacklist, goapAgentState); RouteInfo = actionFactory.RouteInfo; this.GoapAgent = new GoapAgent(logger, goapAgentState, ConfigurableInput, AddonReader, availableActions, blacklist); this.actionThread = new GoalThread(logger, GoapAgent, AddonReader, RouteInfo); // 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; } }); }); }
public CorpseConsumed(ILogger logger, GoapAgentState goapAgentSate) { this.logger = logger; this.goapAgentState = goapAgentSate; AddPrecondition(GoapKey.incombat, false); AddPrecondition(GoapKey.consumecorpse, true); AddEffect(GoapKey.consumecorpse, false); }
public HashSet <GoapGoal> CreateGoals(ClassConfiguration classConfig, IBlacklist blacklist, GoapAgentState goapAgentState) { var availableActions = new HashSet <GoapGoal>(); List <WowPoint> pathPoints, spiritPath; GetPaths(out pathPoints, out spiritPath, classConfig); var wait = new Wait(addonReader); var playerDirection = new PlayerDirection(logger, input, addonReader.PlayerReader); var stopMoving = new StopMoving(input, addonReader.PlayerReader); var castingHandler = new CastingHandler(logger, input, wait, addonReader, classConfig, playerDirection, npcNameFinder, stopMoving); var stuckDetector = new StuckDetector(logger, input, addonReader.PlayerReader, playerDirection, stopMoving); var combatUtil = new CombatUtil(logger, input, wait, addonReader.PlayerReader); var mountHandler = new MountHandler(logger, input, classConfig, wait, addonReader.PlayerReader, stopMoving); var targetFinder = new TargetFinder(logger, input, classConfig, wait, addonReader.PlayerReader, blacklist, npcNameTargeting); var followRouteAction = new FollowRouteGoal(logger, input, wait, addonReader, playerDirection, pathPoints, stopMoving, npcNameFinder, stuckDetector, classConfig, pather, mountHandler, targetFinder); var walkToCorpseAction = new WalkToCorpseGoal(logger, input, addonReader, 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, wait, addonReader.PlayerReader, stopMoving)); if (classConfig.WrongZone.ZoneId > 0) { availableActions.Add(new WrongZoneGoal(addonReader, input, playerDirection, logger, stuckDetector, classConfig)); } if (classConfig.Parallel.Sequence.Count > 0) { availableActions.Add(new ParallelGoal(logger, input, wait, addonReader.PlayerReader, stopMoving, classConfig.Parallel.Sequence, castingHandler)); } if (classConfig.Loot) { if (classConfig.KeyboardOnly) { var lootAction = new LastTargetLoot(logger, input, wait, addonReader, stopMoving, combatUtil); lootAction.AddPreconditions(); availableActions.Add(lootAction); } else { var lootAction = new LootGoal(logger, input, wait, addonReader, stopMoving, classConfig, npcNameTargeting, combatUtil); lootAction.AddPreconditions(); availableActions.Add(lootAction); } if (classConfig.Skin) { availableActions.Add(new SkinningGoal(logger, input, addonReader, wait, stopMoving, npcNameTargeting, combatUtil)); } } try { var genericCombat = new CombatGoal(logger, input, wait, addonReader, stopMoving, classConfig, castingHandler); availableActions.Add(genericCombat); if (addonReader.PlayerReader.Class == PlayerClassEnum.Hunter || addonReader.PlayerReader.Class == PlayerClassEnum.Warlock || addonReader.PlayerReader.Class == PlayerClassEnum.Mage) { availableActions.Add(new TargetPetTarget(input, addonReader.PlayerReader)); } availableActions.Add(new PullTargetGoal(logger, input, wait, addonReader, stopMoving, castingHandler, stuckDetector, classConfig)); availableActions.Add(new ConsumeCorpse(logger, classConfig)); availableActions.Add(new CorpseConsumed(logger, goapAgentState)); foreach (var item in classConfig.Adhoc.Sequence) { availableActions.Add(new AdhocGoal(logger, input, wait, 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, playerDirection, stopMoving, npcNameTargeting, stuckDetector, classConfig, pather, item, blacklist, mountHandler, wait, exec)); 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.UIMapId.Value }, new LineArgs { Spots = spiritPath, Name = "spirithealer", Colour = 3, MapId = addonReader.UIMapId.Value } }); } return(availableActions); }