public void ToggleBotStatus() { if (actionThread != null) { if (!actionThread.Active) { this.GrindSession.StartBotSession(); this.pather.DrawLines(); actionThread.Active = true; botThread = new Thread(() => Task.Factory.StartNew(() => BotThread())); botThread.Start(); } else { actionThread.Active = false; GrindSession.StopBotSession("Stopped By Player", false); AddonReader.LevelTracker.ResetMobsKilled(); AddonReader.LevelTracker.ResetDeath(); } StatusChanged?.Invoke(this, actionThread.Active); } }
public BotController(ILogger logger, IPPather pather, DataConfig dataConfig, IConfiguration configuration) { this.logger = logger; this.pather = pather; this.DataConfig = dataConfig; this.areaDb = new AreaDB(logger, dataConfig); updatePlayerPostion.Start(); wowProcess = new WowProcess(); WowScreen = new WowScreen(logger, wowProcess); WowProcessInput = new WowProcessInput(logger, wowProcess); ExecGameCommand = new ExecGameCommand(logger, WowProcessInput); GrindSessionHandler = new LocalGrindSessionHandler(dataConfig.History); GrindSession = new GrindSession(this, GrindSessionHandler); var frames = DataFrameConfiguration.LoadFrames(); var scad = new StartupConfigAddonData(); configuration.GetSection(StartupConfigAddonData.Position).Bind(scad); if (scad.Mode == "Network") { logger.LogInformation("Using NetworkedAddonDataProvider"); addonDataProvider = new NetworkedAddonDataProvider(logger, scad.myPort, scad.connectTo, scad.connectPort); } else { logger.LogInformation("Using AddonDataProvider"); addonDataProvider = new AddonDataProvider(WowScreen, frames); } AddonReader = new AddonReader(logger, DataConfig, areaDb, addonDataProvider); minimapNodeFinder = new MinimapNodeFinder(WowScreen, new PixelClassifier()); MinimapImageFinder = minimapNodeFinder as IImageProvider; addonThread = new Thread(AddonRefreshThread); addonThread.Start(); // wait for addon to read the wow state var sw = new Stopwatch(); sw.Start(); while (AddonReader.Sequence == 0 || !Enum.GetValues(typeof(PlayerClassEnum)).Cast <PlayerClassEnum>().Contains(AddonReader.PlayerReader.Class)) { if (sw.ElapsedMilliseconds > 5000) { logger.LogWarning("There is a problem with the addon, I have been unable to read the player class. Is it running ?"); sw.Restart(); } Thread.Sleep(100); } logger.LogDebug($"Woohoo, I have read the player class. You are a {AddonReader.PlayerReader.Race} {AddonReader.PlayerReader.Class}."); npcNameFinder = new NpcNameFinder(logger, WowScreen); npcNameTargeting = new NpcNameTargeting(logger, npcNameFinder, WowProcessInput); WowScreen.AddDrawAction(npcNameFinder.ShowNames); WowScreen.AddDrawAction(npcNameTargeting.ShowClickPositions); //ActionFactory = new GoalFactory(AddonReader, logger, wowProcess, npcNameFinder); screenshotThread = new Thread(ScreenshotRefreshThread); screenshotThread.Start(); }
public void Setup() { _controller = Substitute.For <IBotController>(); _grindSessionHandler = Substitute.For <IGrindSessionHandler>(); _grindSession = new GrindSession(_controller, _grindSessionHandler); }