Esempio n. 1
0
        public MissionPageState(int agent_id)
        {
            this.agent_id = agent_id;
            AgentMission mission = Util.FindMission(agent_id);

            name = mission.Name;
            Page = null;
        }
Esempio n. 2
0
        public override bool OnFrameImpl()
        {
            // check if we can see the window
            EVEWindow window = EVEWindow.GetWindowByCaption(name);

            if (window != null && window.IsValid && window.HTML.Length > 0)
            {
                Page = new MissionPage(window.HTML);
                SetDone("Success");
                return(false);
            }

            // try opening the page if we haven't tried already
            if (!tried_opening)
            {
                // TODO: maybe check if the return value of this matters
                Util.FindMission(agent_id).GetDetails();
                tried_opening = true;
            }
            return(true);
        }
Esempio n. 3
0
        void RunCommand(string command)
        {
            if (command == "clear")
            {
                states.Clear();
            }
            else if (command == "exit")
            {
                InnerSpace.Echo("Exiting...");
                // set up the handler for events coming back from InnerSpace
                LavishScript.Events.DetachEventTarget("OnFrame", OnFrame);
                LavishScript.Commands.RemoveCommand("ee");

                lock (lock_) {
                    Monitor.Pulse(lock_);
                }
            }
            else if (command == "update")
            {
                LavishScript.ExecuteCommand("execute evecmd_update woot");
            }
            else if (command == "undock")
            {
                State state = new UndockState();
                TryToEnterState(state);
            }
            else if (command == "gates")
            {
                List <Entity> entities = g.eve.QueryEntities("GroupID = 10");
                g.Print("Found {0} Stargates:", entities.Count);
                int i = 0;
                foreach (Entity entity in entities)
                {
                    g.Print("#{0}: [{2}] {1}", i, entity.Name, entity.ID);
                    i++;
                }
            }
            else if (command == "agents")
            {
                var agents = g.eve.GetAgents();
                if (agents == null)
                {
                    g.Print("EVE.GetAgents() return null");
                }
                else
                {
                    g.Print("Found {0} Agents:", agents.Count);
                }
            }
            else if (command == "stations")
            {
                List <Entity> entities = g.eve.QueryEntities("GroupID = 15");
                g.Print("Found {0} Stations:", entities.Count);
                int i = 0;
                foreach (Entity entity in entities)
                {
                    g.Print("#{0}: [{2}] {1}", i, entity.Name, entity.ID);
                    i++;
                }
            }
            else if (command == "missions")
            {
                List <AgentMission> missions = g.eve.GetAgentMissions();
                if (missions != null && missions.Count != 0)
                {
                    g.Print("Found {0} Missions:", missions.Count);
                    int i = 0;
                    foreach (AgentMission mission in missions)
                    {
                        g.Print("#{0}: {1}", i, mission.Name);
                        g.Print("    AgentID={0}", mission.AgentID);
                        g.Print("    Expires={0}", mission.Expires);
                        g.Print("    State={0}", mission.State);
                        g.Print("    Type={0}", mission.Type);
                        mission.GetDetails(); //opens details window
                        List <BookMark> bookmarks = mission.GetBookmarks();
                        int             j         = 0;
                        g.Print("    {0} Bookmarks:", bookmarks.Count);
                        foreach (BookMark bookmark in bookmarks)
                        {
                            g.Print("    Bookmark #{0}: [{2}] {1}", j, bookmark.Label, bookmark.ID);
                            g.Print("        Type: [{0}] {1}", bookmark.TypeID, bookmark.TypeID);
                            g.Print("        LocationType: {0}", bookmark.LocationType);
                            g.Print("        SolarSystemID: {0}", bookmark.SolarSystemID);
                            j++;
                        }
                        i++;
                    }
                }
                else if (missions == null)
                {
                    g.Print("Getting missions failed");
                }
                else
                {
                    g.Print("No missions found");
                }
            }
            else if (command.StartsWith("printwindow "))
            {
                string    window_name = command.Substring(12);
                EVEWindow window      = EVEWindow.GetWindowByName(window_name);
                if (window == null || !window.IsValid)
                {
                    window = EVEWindow.GetWindowByCaption(window_name);
                }

                if (window != null && window.IsValid)
                {
                    g.Print(window.Caption);
                    g.Print(window.HTML);

                    try // to parse some basics
                    {
                        MissionPage page = new MissionPage(window.HTML);
                        g.Print("Title: {0}", page.Title);
                        g.Print("CargoID: {0}", page.CargoID);
                        g.Print("Volume: {0}", page.CargoVolume);
                    }
                    catch { }
                }
                else
                {
                    g.Print("window \"{0}\" not found", window_name);
                }
            }
            else if (command == "printitems")
            {
                // print the items in station
                if (!g.me.InStation)
                {
                    g.Print("Not in station...");
                }
                else
                {
                    List <Item> items = g.me.GetHangarItems();
                    if (items == null)
                    {
                        g.Print("Failed to GetHangerItems");
                    }
                    else
                    {
                        int i = 0;
                        g.Print("Found {0} Items:", items.Count);
                        foreach (Item item in items)
                        {
                            g.Print("#{0}: [{2}] {1} x{3}", i, item.Name, item.ID, item.Quantity);
                            g.Print("    Description={0}", item.Description);
                            g.Print("    Type=[{0}] {1}", item.TypeID, item.Type);
                            g.Print("    Category=[{0}] {1}", item.CategoryID, item.Category);
                            g.Print("    BasePrice={0}", item.BasePrice);
                            g.Print("    UsedCargoCapacity={0}", item.UsedCargoCapacity);
                            i++;
                        }
                    }
                }
            }
            else if (command.StartsWith("printagent "))
            {
                int   id    = Int32.Parse(command.Substring(11));
                Agent agent = new Agent("ByID", id);
                if (agent != null && agent.IsValid)
                {
                    g.Print("Name: {0}", agent.Name);
                    g.Print("Station: [{0}] {1}", agent.StationID, agent.Station);
                    g.Print("Division: [{0}] {1}", agent.DivisionID, agent.Division);
                    g.Print("StandingTo: {0}", agent.StandingTo);
                    g.Print("SolarSystemID: {0}", agent.Solarsystem.ID);
                    List <DialogString> responses = agent.GetDialogResponses();
                    int i = 0;
                    g.Print("{0} Dialog Responses:", responses.Count);
                    foreach (DialogString response in responses)
                    {
                        g.Print("    Response #{0}: {1}", i, response.Text);
                        i++;
                    }
                }
                else
                {
                    g.Print("Agent not found");
                }
            }
            else if (command == "printcargo")
            {
                List <Item> items = g.me.Ship.GetCargo();

                g.Print("Found {0} Items:", items.Count);
                int i = 0;
                foreach (Item item in items)
                {
                    g.Print("#{0} {1}", i, item.Name);
                    g.Print("    Category: [{0}] {1} ({2})", item.CategoryID, item.Category, item.CategoryType.ToString());
                    g.Print("    Description: {0}", item.Description);
                    g.Print("    Group: [{0}] {1}", item.GroupID, item.Group);
                    i++;
                }
            }
            else if (command == "printroids")
            {
                List <Entity> roids = g.eve.QueryEntities("CategoryID = 25");
                g.Print("Found {0} Asteroids:", roids.Count);
                int i = 0;
                foreach (Entity roid in roids)
                {
                    if (i >= 10)
                    {
                        break;
                    }
                    g.Print("#{0} {1}", i, roid.Name);
                    g.Print("    Distance: {0}", roid.Distance);
                    g.Print("    Type: [{0}] {1}", roid.TypeID, roid.Type);
                    g.Print("    Category: [{0}] {1} ({2})", roid.CategoryID, roid.Category, roid.CategoryType);
                    g.Print("    Location: {0},{1},{2}", roid.X, roid.Y, roid.Z);
                    g.Print("    IsActiveTarget: {0} IsLockedTarget: {1}", roid.IsActiveTarget ? "Yes" : "No", roid.IsLockedTarget ? "Yes" : "No");
                    i++;
                }
            }
            else if (command.StartsWith("warp "))
            {
                State state = new WarpState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "dock")
            {
                State state = new DockState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "goto")
            {
                State state = new GotoState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "domission")
            {
                State state = new MissionState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "dodropoff")
            {
                State state = new DoDropoffState(command);
                TryToEnterState(state);
            }
            else if (command.Split(' ')[0] == "mineloop")
            {
                State state = new MineLoopState(command);
                TryToEnterState(state);
            }
            else if (command == "unloadore")
            {
                State state = new UnloadOreState();
                TryToEnterState(state);
            }
            else if (command.StartsWith("travel "))
            {
                State state = new TravelToStationState(command);
                TryToEnterState(state);
            }
            else if (command == "runlasers")
            {
                TryToEnterState(new RunMiningLasersState());
            }
        }
Esempio n. 4
0
        public override bool OnFrameImpl()
        {
            if (substate != null)
            {
                if (substate.OnFrame())
                {
                    return(true);
                }
            }

            if (substate is CompleteQuestState)
            {
                SetDone(substate.Result);
                return(false);
            }

            // first, make sure we have the mission page
            if (page == null)
            {
                if (page_state == null)
                {
                    page_state = new MissionPageState(agent_id);
                    page_state.OnFrame();

                    if (page_state.IsDone)
                    {
                        page = page_state.Page;
                    }
                    else
                    {
                        substate = page_state;
                        return(true);
                    }
                }
                else if (page_state.Page != null)
                {
                    page     = page_state.Page;
                    substate = null;
                }
                else
                {
                    SetDone("We failed to get the mission page - aborting");
                    return(false);
                }
            }

            bool items_in_cargo = ItemsInCargoBay();

            if (items_delivered)
            {
                // check if we're done
                Agent agent = new Agent("ByID", agent_id);
                if (g.me.InStation && g.me.StationID == agent.StationID)
                {
                    SetDone("Finished Courier mission - please turn in");
                    return(false);
                }
                else
                {
                    substate = new TravelToStationState(agent.StationID, agent.Solarsystem.ID);
                    substate.OnFrame();
                    return(true);
                }
            }
            else if (items_in_cargo)
            {
                BookMark dropoff = Util.FindDropoff(agent_id);

                // the dropoff bookmark ID is the same as the station ID (if its a station, all we support atm)
                if (g.me.InStation && g.me.StationID == dropoff.ID)
                {
                    substate = new CompleteQuestState(agent_id);
                    return(true);
                }
                else
                {
                    substate = new TravelToStationState(dropoff.ID, dropoff.SolarSystemID);
                    substate.OnFrame();
                    return(true);
                }
            }
            else
            {
                BookMark pickup = Util.FindPickup(agent_id);

                // the dropoff bookmark ID is the same as the station ID (if its a station, all we support atm)
                if (g.me.InStation && g.me.StationID == pickup.ID)
                {
                    List <Item> hanger_items = g.me.GetHangarItems();
                    foreach (Item hanger in hanger_items)
                    {
                        if (hanger.TypeID == page.CargoID)
                        {
                            hanger.MoveToMyShip();
                        }
                    }

                    if (ItemsInCargoBay())
                    {
                        return(OnFrame());
                    }
                    else
                    {
                        SetDone("Didn't find all the things we needed");
                        return(false);
                    }
                }
                else
                {
                    substate = new TravelToStationState(pickup.ID, pickup.SolarSystemID);
                    substate.OnFrame();
                    return(true);
                }
            }
        }