Exemple #1
0
        /// <summary>
        ///     Return what "eve.LocalSvc" would return, unless the service wasn't started yet
        /// </summary>
        /// <param name="svc"></param>
        /// <returns></returns>
        /// <remarks>Use at your own risk!</remarks>
        public PyObject GetLocalSvc(string svc)
        {
            PyObject service;

            // Do we have a cached version (this is to stop overloading the LocalSvc call)
            if (_localSvcCache.TryGetValue(svc, out service))
            {
                return(service);
            }

            // First try to get it from services
            service = PySharp.Import("__builtin__").Attribute("sm").Attribute("services").DictionaryItem(svc);

            // Add it to the cache (it doesn't matter if its not valid)
            _localSvcCache.Add(svc, service);

            // If its valid, return the service
            if (service.IsValid)
            {
                return(service);
            }

            // Start the service in a ThreadedCall
            var localSvc = PySharp.Import("__builtin__").Attribute("sm").Attribute("GetService");

            ThreadedCall(localSvc, svc);

            // Return an invalid PyObject (so that LocalSvc can start the service)
            return(global::DirectEve.PySharp.PySharp.PyZero);
        }
Exemple #2
0
        /// <summary>
        ///     Refine items from the hangar floor
        /// </summary>
        /// <param name="items"></param>
        /// <returns></returns>
        public bool ReprocessStationItems(IEnumerable <DirectItem> items)
        {
            if (items == null)
            {
                return(false);
            }

            if (items.Any(i => !i.PyItem.IsValid))
            {
                return(false);
            }

            if (!Session.IsInStation)
            {
                return(false);
            }

            if (items.Any(i => i.LocationId != Session.StationId))
            {
                return(false);
            }

            var Refine = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.invItemFunctions").Attribute("Refine");

            return(ThreadedCall(Refine, items.Select(i => i.PyItem)));
        }
Exemple #3
0
        /// <summary>
        ///     Make this your active target
        /// </summary>
        /// <returns></returns>
        public bool MakeActiveTarget()
        {
            if (!IsTarget)
            {
                return(false);
            }

            if (IsActiveTarget)
            {
                return(true);
            }

            // Even though we uthread the thing, expect it to be instant
            var currentActiveTarget = DirectEve.Entities.FirstOrDefault(t => t.IsActiveTarget);

            if (currentActiveTarget != null)
            {
                currentActiveTarget.IsActiveTarget = false;
            }

            // Switch active targets
            var activeTarget = PySharp.Import("state").Attribute("activeTarget");

            return(IsActiveTarget = DirectEve.ThreadedLocalSvcCall("state", "SetState", Id, activeTarget, 1));
        }
Exemple #4
0
 internal long getServiceMask()
 {
     if (!Session.IsInStation)
     {
         return(0);
     }
     return((long)PySharp.Import("__builtin__").Attribute("eve").Attribute("stationItem").Attribute("serviceMask"));
 }
Exemple #5
0
        private PyObject Evaluate(PySharp.PySharp pySharp, PyObject pyObject)
        {
            // TODO: Better part splitting (e.g. bla('bla', const.bla)
            var parts = _evaluate.Split('.');
            if (parts.Length == 0)
            {
                // TODO: List imports
                return null;
            }

            if (pyObject == null)
                pyObject = pySharp.Import(parts[0]);

            for (var i = 1; i < parts.Length; i++)
            {
                if (parts[i].Contains("("))
                {
                    // TODO: Call
                }
                else if (parts[i].Contains("["))
                {
                    var attr = parts[i].Substring(0, parts[i].IndexOf('['));

                    var key = parts[i].Substring(parts[i].IndexOf('[') + 1, parts[i].IndexOf(']') - parts[i].IndexOf('[') - 1);
                    if (key.StartsWith("'") || key.StartsWith("\""))
                        key = key.Substring(1, key.Length - 2);

                    if (!string.IsNullOrEmpty(attr))
                        pyObject = pyObject.Attribute(attr);

                    if (pyObject.GetPyType() == PyType.DictType ||
                        pyObject.GetPyType() == PyType.DerivedDictType ||
                        pyObject.GetPyType() == PyType.DictProxyType ||
                        pyObject.GetPyType() == PyType.DerivedDictProxyType)
                    {
                        var dict = pyObject.ToDictionary();

                        pyObject = PySharp.PySharp.PyZero;
                        foreach (var dictItem in dict)
                        {
                            if (GetPyValue(dictItem.Key) == key)
                                pyObject = dictItem.Value;
                        }
                    }
                    else
                    {
                        int index;
                        pyObject = int.TryParse(key, out index) ? pyObject.Item(index) : PySharp.PySharp.PyZero;
                    }
                }
                else
                {
                    pyObject = pyObject.Attribute(parts[i]);
                }
            }

            return pyObject;
        }
Exemple #6
0
        public bool RemoveOffer()
        {
            if (State != (int)PySharp.Import("__builtin__").Attribute("const").Attribute("agentMissionStateOffered"))
            {
                return(false);
            }

            return(DirectEve.ThreadedLocalSvcCall("agents", "RemoveOfferFromJournal", _pyAgentId));
        }
Exemple #7
0
        public double AveragePrice()
        {
            //if (!DirectEve.HasSupportInstances())
            //{
            //    DirectEve.Log("DirectEve: Error: This method requires a support instance.");
            //    return -1;
            //}

            return((double)PySharp.Import("util").Call("GetAveragePrice", PyItem));
        }
Exemple #8
0
        /// <summary>
        ///     Open the repairshop window
        /// </summary>
        public void OpenRepairShop()
        {
            if (!Session.IsInStation)
            {
                return;
            }
            var form = PySharp.Import("form");

            ThreadedCall(form.Attribute("RepairShopWindow").Attribute("Open"));
        }
Exemple #9
0
        /// <summary>
        ///     Abandons all wrecks. Make sure to only call this on a wreck.
        /// </summary>
        /// <returns>false if entity is not a wreck</returns>
        public bool AbandonAllWrecks()
        {
            if (GroupId != (int)DirectEve.Const.GroupWreck)
            {
                return(false);
            }

            var AbandonAllLoot = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.menuFunctions").Attribute("AbandonAllLoot");

            return(DirectEve.ThreadedCall(AbandonAllLoot, Id));
        }
Exemple #10
0
        public bool ActivatePLEX()
        {
            if (TypeId != 29668)
            {
                return(false);
            }

            var ApplyPilotLicence = PySharp.Import("__builtin__").Attribute("sm").Call("RemoteSvc", "userSvc").Attribute("ApplyPilotLicence");

            return(DirectEve.ThreadedCall(ApplyPilotLicence, ItemId));
        }
Exemple #11
0
        /// <summary>
        ///     Perform a uthread.new(pyCall, parms) call
        /// </summary>
        /// <param name="pyCall"></param>
        /// <param name="keywords"></param>
        /// <param name="parms"></param>
        /// <returns></returns>
        /// <remarks>Use at your own risk!</remarks>
        public bool ThreadedCallWithKeywords(PyObject pyCall, Dictionary <string, object> keywords, params object[] parms)
        {
            // Check specifically for this, as the call has to be valid (e.g. not null or none)
            if (!pyCall.IsValid)
            {
                return(false);
            }

            RegisterAppEventTime();
            return(!PySharp.Import("uthread").CallWithKeywords("new", keywords, (new object[] { pyCall }).Concat(parms).ToArray()).IsNull);
        }
Exemple #12
0
        /// <summary>
        ///     KeepAtRange target
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        public bool KeepAtRange(int range)
        {
            if (DateTime.Now.Subtract(lastKeepAtRange).TotalSeconds < 10)
            {
                return(false);
            }
            lastKeepAtRange = DateTime.Now;

            var KeepAtRange = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.movementFunctions").Attribute("KeepAtRange");

            return(DirectEve.ThreadedCall(KeepAtRange, Id, range));
        }
Exemple #13
0
        /// <summary>
        ///     Activate this slot, this could make it main slot (if its slot 1 or 2) or login the character (slot 0)
        /// </summary>
        /// <returns></returns>
        public bool Activate()
        {
            //if (!DirectEve.HasSupportInstances())
            //{
            //    DirectEve.Log("DirectEve: Error: This method requires a support instance.");
            //    return false;
            //}

            var selectSlot = PySharp.Import("__builtin__").Attribute("uicore").Attribute("layer").Attribute("charsel").Attribute("EnterGameWithCharacter");

            return(DirectEve.ThreadedCall(selectSlot, _pySlot));
        }
Exemple #14
0
        /// <summary>
        ///     Start a system scan; i.e. click the Analyze button.
        /// </summary>
        /// <returns>false if scan already running.  true if new scan was started</returns>
        public bool Analyze()
        {
            // only perform a scan for paid users
            var scanningProbes = PySharp.Import("__builtin__").Attribute("sm").Attribute("services").DictionaryItem("scanSvc").Attribute("scanHandler").Attribute("scanningProbes");

            // Check for an active scan.  If we call Analyze while a scan is running Eve will throw an exception
            if (scanningProbes.IsValid == false)
            {
                _systemScanResults = null; // free old results
                return(DirectEve.ThreadedCall(PyWindow.Attribute("Analyze")));
            }


            return(false);
        }
Exemple #15
0
        /// <summary>
        ///     Board this ship
        /// </summary>
        /// <returns>false if entity is player or out of range</returns>
        public bool BoardShip()
        {
            if (IsPc)
            {
                return(false);
            }

            if (Distance > 6500)
            {
                return(false);
            }

            var Board = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.menuFunctions").Attribute("Board");

            return(DirectEve.ThreadedCall(Board, Id));
        }
Exemple #16
0
        /// <summary>
        ///     Board this ship from a ship maintanance bay!
        /// </summary>
        /// <returns>false if entity is player or out of range</returns>
        public bool BoardShipFromShipMaintBay()
        {
            if (CategoryId != (int)DirectEve.Const.CategoryShip)
            {
                return(false);
            }

            if (IsSingleton)
            {
                return(false);
            }

            var Board = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.menuFunctions").Attribute("Board");

            return(DirectEve.ThreadedCall(Board, ItemId));
        }
        /// <summary>
        ///     Open the current container view in a new window
        /// </summary>
        /// <returns></returns>
        public bool OpenAsSecondary()
        {
            var invID = PyWindow.Attribute("currInvID");
            //check if it's already open, in that case do nothing.
            var windows       = DirectEve.Windows.OfType <DirectContainerWindow>();
            var lookForInvID  = (string)invID.ToList().First();
            var alreadyOpened = windows.FirstOrDefault(w => w.Name.Contains(lookForInvID) && !w.IsPrimary());

            if (alreadyOpened != null)
            {
                return(true);
            }


            var form     = PySharp.Import("form");
            var keywords = new Dictionary <string, object>();

            keywords.Add("invID", invID);
            keywords.Add("usePrimary", false);
            return(DirectEve.ThreadedCallWithKeywords(form.Attribute("Inventory").Attribute("OpenOrShow"), keywords));
        }
Exemple #18
0
        /// <summary>
        ///     Inject the skill into your brain
        /// </summary>
        /// <returns></returns>
        public bool InjectSkill()
        {
            if (CategoryId != (int)DirectEve.Const.CategorySkill)
            {
                return(false);
            }

            if (!DirectEve.Session.StationId.HasValue || LocationId != DirectEve.Session.StationId)
            {
                return(false);
            }

            if (ItemId == 0 || !PyItem.IsValid)
            {
                return(false);
            }

            var InjectSkillIntoBrain = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.invItemFunctions").Attribute("InjectSkillIntoBrain");

            return(DirectEve.ThreadedCall(InjectSkillIntoBrain, new List <PyObject> {
                PyItem
            }));
        }
Exemple #19
0
        /// <summary>
        ///     Assembles this ship
        /// </summary>
        /// <returns></returns>
        /// <remarks>
        ///     Fails if the current location is not the same as the current station and if its not a CategoryShip and is not
        ///     allready assembled
        /// </remarks>
        public bool AssembleShip()
        {
            if (LocationId != DirectEve.Session.StationId)
            {
                return(false);
            }

            if (CategoryId != (int)DirectEve.Const.CategoryShip)
            {
                return(false);
            }

            if (IsSingleton)
            {
                return(false);
            }

            var AssembleShip = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.invItemFunctions").Attribute("AssembleShip");

            return(DirectEve.ThreadedCall(AssembleShip, new List <PyObject>()
            {
                PyItem
            }));
        }
Exemple #20
0
        /// <summary>
        ///     Eject from your current ship
        /// </summary>
        /// <returns></returns>
        public bool EjectFromShip()
        {
            var Eject = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.menuFunctions").Attribute("Eject");

            return(DirectEve.ThreadedCall(Eject));
        }
Exemple #21
0
        public bool Approach()
        {
            var approachLocation = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.movementFunctions").Attribute("ApproachLocation");

            return(DirectEve.ThreadedCall(approachLocation, PyBookmark));
        }
Exemple #22
0
        public bool WarpTo(double distance)
        {
            var warpToBookmark = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.movementFunctions").Attribute("WarpToBookmark");

            return(DirectEve.ThreadedCall(warpToBookmark, PyBookmark, distance));
        }
Exemple #23
0
 /// <summary>
 ///     Register app event time
 /// </summary>
 private void RegisterAppEventTime()
 {
     PySharp.Import("__builtin__").Attribute("uicore").Attribute("uilib").Call("RegisterAppEventTime");
 }
Exemple #24
0
        /// <summary>
        ///     Open the fitting management window
        /// </summary>
        public void OpenFitingManager()
        {
            var form = PySharp.Import("form");

            ThreadedCall(form.Attribute("FittingMgmt").Attribute("Open"));
        }
Exemple #25
0
        /// <summary>
        ///     Broadcast scatter events.  Use with caution.
        /// </summary>
        /// <param name="evt">The event name.</param>
        /// <returns></returns>
        public bool ScatterEvent(string evt)
        {
            var scatterEvent = PySharp.Import("__builtin__").Attribute("sm").Attribute("ScatterEvent");

            return(ThreadedCall(scatterEvent, evt));
        }
Exemple #26
0
        /// <summary>
        ///     Activate (Acceleration Gates only)
        /// </summary>
        /// <returns></returns>
        public bool Activate()
        {
            var DockOrJumpOrActivateGate = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.movementFunctions").Attribute("DockOrJumpOrActivateGate");

            return(DirectEve.ThreadedCall(DockOrJumpOrActivateGate, Id));
        }
Exemple #27
0
        /// <summary>
        ///     Warp to target at range
        /// </summary>
        /// <returns></returns>
        public bool WarpTo(double range)
        {
            var WarpToItem = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.movementFunctions").Attribute("WarpToItem");

            return(DirectEve.ThreadedCall(WarpToItem, Id, range));
        }
Exemple #28
0
        /// <summary>
        ///     Orbit target
        /// </summary>
        /// <param name="range"></param>
        /// <returns></returns>
        public bool Orbit(int range)
        {
            var Orbit = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.movementFunctions").Attribute("Orbit");

            return(DirectEve.ThreadedCall(Orbit, Id, range));
        }
Exemple #29
0
        public bool OpenShipMaintenanceBay(long itemID)
        {
            var OpenShipMaintenanceBayShip = PySharp.Import("eve.client.script.ui.services.menuSvcExtras.openFunctions").Attribute("OpenShipMaintenanceBayShip");

            return(ThreadedCall(OpenShipMaintenanceBayShip, itemID, global::DirectEve.PySharp.PySharp.PyNone));
        }