/// <summary> /// Main constructor /// </summary> /// <param name="p">the client's process object</param> public Client(Process p) { Process = p; Process.Exited += new EventHandler(process_Exited); Process.EnableRaisingEvents = true; // Wait until we can really access the process Process.WaitForInputIdle(); while (Process.MainWindowHandle == IntPtr.Zero) { Process.Refresh(); System.Threading.Thread.Sleep(5); } // Save a copy of the handle so the process doesn't have to be opened // every read/write operation Handle = Util.WinAPI.OpenProcess(Util.WinAPI.PROCESS_ALL_ACCESS, 0, (uint)Process.Id); PathFinder = new Pokemon.Util.AStarPathFinder(this); Inventory = new Objects.Inventory(this); BattleList = new Objects.BattleList(this); Map = new Objects.Map(this); Memory = new MemoryHelper(this); Window = new Window(this); IO = new IOHelper(this); Login = new LoginHelper(this); Dll = new DllHelper(this); Input = new InputHelper(this); Player = new PlayerHelper(this); // Save the start time (it isn't changing) startTime = Memory.ReadInt32(Addresses.Client.StartTime); }