public static double GetDouble(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <double>());
     }
 }
Exemplo n.º 2
0
        internal static T GetFromIndexMember <T>(ILSObject obj, string memberName, string lsTypeName, int number, params string[] args)
        {
            // argument is 0-based
            number += 1;

            if (obj == null || !obj.IsValid)
            {
                return(default(T));
            }

            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                var allargs = PrefixArray(index.LSReference, args);

                using (var retval = obj.GetMember(memberName, allargs))
                {
                    if (LavishScriptObject.IsNullOrInvalid(retval) || retval.GetValue <int>() < number)
                    {
                        return(default(T));
                    }
                }

                var member = GetIndexMember <T>(index, number);
                return(member);
            }
        }
Exemplo n.º 3
0
 public static Int64 GetInt64FromLSO(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <Int64>());
     }
 }
Exemplo n.º 4
0
 public static double?GetNullableDoubleFromLSO(this ILSObject obj, string member, params string[] args)
 {
     using (var lavishScriptObject = obj.GetMember(member, args))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (double?)lavishScriptObject.GetValue <double>());
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Translate an index of a given LavishScript type returned from the given member on the given object to a List of a .NET datatype equivalent.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="obj"></param>
        /// <param name="memberName"></param>
        /// <param name="lsTypeName"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public static List <T> GetListFromMember <T>(this ILSObject obj, string memberName, string lsTypeName, params string[] args)
        {
            //var methodName = "GetListFromMember";
            //Tracing.SendCallback(methodName, MemberName, LSTypeName);

            if (obj == null || !obj.IsValid)
            {
                return(null);
            }

            //Tracing.SendCallback(methodName, "new index");
            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                //Tracing.SendCallback(methodName, "arg condensing");
                var allargs = PrefixArray(index.LSReference, args);

                //Tracing.SendCallback(methodName, "getmember retval");
                using (var retval = obj.GetMember(memberName, allargs))
                {
                    if (LavishScriptObject.IsNullOrInvalid(retval))
                    {
                        return(null);
                    }
                }

                //Tracing.SendCallback(methodName, "index to list");
                var list = IndexToList <T>(index, lsTypeName);

                //Tracing.SendCallback(methodName, "invalidate");

                //Tracing.SendCallback(methodName, "return");
                return(list);
            }
        }
Exemplo n.º 6
0
 public static float?GetNullableFloatFromLSO(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (float?)lavishScriptObject.GetValue <float>());
     }
 }
 public static int?GetNullableInt(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (int?)lavishScriptObject.GetValue <int>());
     }
 }
 /// <summary>
 /// Retrieves the requested unsigned integer member
 /// </summary>
 /// <param name="obj">this</param>
 /// <param name="member">the member to retrieve</param>
 /// <returns>LavishScriptObject integer member value</returns>
 public static uint GetUIntFromLSO(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? 0 : lavishScriptObject.GetValue <uint>());
     }
 }
Exemplo n.º 9
0
        public override void PopulateEntities()
        {
            var methodName = "PopulateEntities";

            LogTrace(methodName);

            if (_isxeveProvider.Eve.EntitiesCount == 0)
            {
                LogMessage(methodName, LogSeverityTypes.Standard, "Error: ISXEVE sees 0 entities. Forcing entity population.");
                _isxeveProvider.Eve.PopulateEntities(true);
            }

            StartMethodProfiling("EVE.QueryEntities");
            var entities = _isxeveProvider.Eve.QueryEntities();

            EndMethodProfiling();
            //StartMethodProfiling("SortEntities");
            //entities = entities.OrderBy<Entity, double>(x => x.Distance).ToList();
            //EndMethodProfiling();

            StartMethodProfiling("CreateEntityWrappers");
            if (entities != null)
            {
                //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Debug,
                //methodName, String.Format("Got {0} entities from query.", entities.Count)));
                //StartMethodProfiling("BuildEntityWrappers");
                foreach (var entity in entities)
                {
                    if (LavishScriptObject.IsNullOrInvalid(entity))
                    {
                        continue;
                    }

                    //Ignore certain entities
                    if (entity.CategoryID == (int)CategoryIDs.Charge)
                    {
                        continue;
                    }

                    var entityWrapper = new EntityWrapper(entity);
                    _entityWrappers.Add(entityWrapper);

                    try
                    {
                        _entityWrappersById.Add(entityWrapper.ID, entityWrapper);
                    }
                    catch (Exception)
                    {
                        LogMessage(methodName, LogSeverityTypes.Standard, "Error: An entity matching entity \"{0}\" id {1} is already being tracked.",
                                   entityWrapper.ID, entityWrapper.Name);
                    }
                }
                //EndMethodProfiling();
            }
            else
            {
                LogMessage(methodName, LogSeverityTypes.Debug, "Got null result from QueryEntities.");
            }
            EndMethodProfiling();
        }
 public static string GetString(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : lavishScriptObject.GetValue <string>());
     }
 }
Exemplo n.º 11
0
        internal static T GetFromIndexMethod <T>(ILSObject obj, string methodName, string lsTypeName, int number, params string[] args)
        {
            // argument is 0-based
            number += 1;

            if (obj == null || !obj.IsValid || number <= 0)
            {
                return(default(T));
            }

            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                var allargs = PrefixArray(index.LSReference, args);

                if (!obj.ExecuteMethod(methodName, allargs))
                {
                    return(default(T));
                }

                using (var used = index.GetMember("Used"))
                {
                    // if it failed or we want one off the end, return
                    if (LavishScriptObject.IsNullOrInvalid(used) || used.GetValue <int>() < number)
                    {
                        return(default(T));
                    }
                }

                var member = GetIndexMember <T>(index, number);
                return(member);
            }
        }
 public static int GetInt(this ILSObject obj, string member, params string[] args)
 {
     using (var lavishScriptObject = obj.GetMember(member, args))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <int>());
     }
 }
Exemplo n.º 13
0
        public CachedDrone(ActiveDrone activeDrone)
        {
            _activeDrone = activeDrone;
            State        = activeDrone.State;
            Id           = activeDrone.ID;

            var activeDroneEntity = activeDrone.ToEntity;

            if (LavishScriptObject.IsNullOrInvalid(activeDroneEntity) || activeDroneEntity.ID <= 0)
            {
                Distance      = -1;
                ShieldPct     = -1;
                ArmorPct      = -1;
                IsEntityValid = false;
            }
            else
            {
                Distance       = activeDroneEntity.Distance;
                ShieldPct      = activeDroneEntity.ShieldPct;
                ArmorPct       = activeDroneEntity.ArmorPct;
                TargetEntityId = LavishScriptObject.IsNullOrInvalid(activeDrone.Target) ? -1 : activeDrone.Target.ID;
                IsEntityValid  = true;
                //StealthBot.Logging.LogMessage("CachedDrone", "CachedDrone", LogSeverityTypes.Debug, "ActiveDrone dump: ID {0}, Name \"{1}\", State {2}, Distance {3}",
                //activeDrone.ID, activeDrone.ToEntity.Name, activeDrone.State, activeDrone.ToEntity.Distance);
            }

            //TargetEntityID = activeDrone.Target.ID;
        }
Exemplo n.º 14
0
        private static void TestGetLocalGridEntities(Character me, EVE.ISXEVE.EVE eve, ILogger logger)
        {
            //var entities = EntityRepository.GetLocalGridEntities(me, eve);
            eve.RefreshStandings();
            var entities = eve.QueryEntities().Where(x => x.IsPC);

            //var anObj = LavishScript.Objects.GetObject("Local", "Romvex");
            //logger.Log(anObj.ToString());

            var pilot = new Pilot("Romvex ");

            logger.Log(pilot.ToString());

            foreach (var entity in entities)
            {
                logger.Log(entity.Name);
                logger.Log(LavishScriptObject.IsNullOrInvalid(entity.Owner.ToFleetMember).ToString());
                logger.Log(entity.Owner.CharID.ToString());
                logger.Log(entity.Owner.Corp.ID.ToString());
                logger.Log(entity.AllianceID.ToString());
                var standing = me.StandingTo(entity.CharID, entity.Corp.ID, entity.AllianceID);
                logger.Log(standing.AllianceToAlliance.ToString());
                logger.Log(standing.AllianceToCorp.ToString());
                logger.Log(standing.AllianceToPilot.ToString());
                logger.Log(standing.CorpToAlliance.ToString());
                logger.Log(standing.CorpToCorp.ToString());
                logger.Log(standing.CorpToPilot.ToString());
                logger.Log(standing.MeToAlliance.ToString());
                logger.Log(standing.MeToCorp.ToString());
                logger.Log(standing.MeToPilot.ToString());
            }
        }
Exemplo n.º 15
0
 public static bool GetBoolFromLSO(this ILSObject obj, string member, params string[] args)
 {
     using (var lavishScriptObject = obj.GetMember(member, args))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? false : lavishScriptObject.GetValue <bool>());
     }
 }
 public static bool?GetNullableBool(this ILSObject obj, string member, params string[] args)
 {
     using (var lavishScriptObject = obj.GetMember(member, args))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (bool?)lavishScriptObject.GetValue <bool>());
     }
 }
 public static float GetFloat(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <float>());
     }
 }
 /// <summary>
 /// Retireves the requested boolean member
 /// </summary>
 /// <param name="obj">this</param>
 /// <param name="member">the member to retrieve</param>
 /// <returns>LavishScriptObject boolean member value</returns>
 public static bool GetBoolFromLSO(this ILSObject obj, string member)
 {
     using (var lavishScriptObject = obj.GetMember(member))
     {
         return(!LavishScriptObject.IsNullOrInvalid(lavishScriptObject) && lavishScriptObject.GetValue <bool>());
     }
 }
Exemplo n.º 19
0
        public static bool IsFleetMember(this Entity entity)
        {
            var isInvalid = LavishScriptObject.IsNullOrInvalid(entity.Owner.ToFleetMember);
            var inFleet   = !isInvalid;

            return(inFleet);
        }
Exemplo n.º 20
0
        private bool GetBookmarks()
        {
            var methodName = "GetBookmarks";

            LogTrace(methodName);

            //First do pickup bookmark
            if (Core.StealthBot.Config.CargoConfig.PickupLocation.BookmarkLabel != String.Empty)
            {
                _pickupBookmark = null;

                var cachedBookMark = Core.StealthBot.BookMarkCache.FirstBookMarkStartingWith(
                    Core.StealthBot.Config.CargoConfig.PickupLocation.BookmarkLabel, false);

                if (cachedBookMark != null)
                {
                    _pickupBookmark = Core.StealthBot.BookMarkCache.GetBookMarkFor(cachedBookMark);
                }
            }

            //Next, dropoff bookmark
            if (Core.StealthBot.Config.CargoConfig.DropoffLocation.BookmarkLabel != String.Empty)
            {
                _dropoffBookmark = null;

                var cachedBookMark = Core.StealthBot.BookMarkCache.FirstBookMarkStartingWith(
                    Core.StealthBot.Config.CargoConfig.DropoffLocation.BookmarkLabel, false);

                _dropoffBookmark = Core.StealthBot.BookMarkCache.GetBookMarkFor(cachedBookMark);
            }

            return(!LavishScriptObject.IsNullOrInvalid(_pickupBookmark) && !LavishScriptObject.IsNullOrInvalid(_dropoffBookmark));
        }
Exemplo n.º 21
0
        internal static T GetFromIndexMethod <T>(ILSObject Obj, string MethodName, string LSTypeName, int number, params string[] Args)
        {
            // argument is 0-based
            number += 1;

            if (Obj == null || !Obj.IsValid || number <= 0)
            {
                return(default(T));
            }

            LavishScriptObject Index = LavishScript.Objects.NewObject("index:" + LSTypeName);

            string[] allargs = PrefixArray <string>(Index.LSReference, Args);

            Obj.ExecuteMethod(MethodName, allargs);

            LavishScriptObject used = Index.GetMember("Used");

            // if it failed or we want one off the end, return
            if (LavishScriptObject.IsNullOrInvalid(used) || used.GetValue <int>() < number)
            {
                return(default(T));
            }

            return(GetIndexMember <T>(Index, number));
        }
        /// <summary>
        /// Retrieves the requested boolean member based on the arguments provided
        /// </summary>
        /// <param name="obj">this</param>
        /// <param name="member">the member to retrieve</param>
        /// <param name="args"></param>
        /// <returns>LavishScriptObject boolean member value</returns>
// ReSharper disable MethodOverloadWithOptionalParameter
        public static bool GetBoolFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
        {
            using (var lavishScriptObject = obj.GetMember(member, args))
            {
                return(!LavishScriptObject.IsNullOrInvalid(lavishScriptObject) && lavishScriptObject.GetValue <bool>());
            }
        }
Exemplo n.º 23
0
        public override void InFrameCleanup()
        {
            if (!LavishScriptObject.IsNullOrInvalid(_toEntity))
            {
                _toEntity.Dispose();
            }

            Approaching = null;
        }
Exemplo n.º 24
0
        private int GetSkillLevel(string skillName)
        {
            var methodName = "GetSkillLevel";

            LogTrace(methodName, "Skill name: {0}", skillName);

            var skill = StealthBot.MeCache.Me.Skill(skillName);

            return(!LavishScriptObject.IsNullOrInvalid(skill) ? skill.Level : 0);
        }
        /// <summary>
        /// Retrieves the requested integer member based on the arguments provided
        /// </summary>
        /// <param name="obj">this</param>
        /// <param name="member">the member to retrieve</param>
        /// <param name="args">string array of arguments to pass to the member</param>
        /// <returns>LavishScriptObject integer member value</returns>
// ReSharper disable MethodOverloadWithOptionalParameter
        public static int?GetNullableIntFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
        {
            using (var lavishScriptObject = obj.GetMember(member, args))
            {
                return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
                    ? null
                    : (int?)lavishScriptObject.GetValue <int>());
            }
        }
Exemplo n.º 26
0
        public void InitializeStationCorpHangars()
        {
            var childWindow = GetStationCorpHangarsContainerChildWindow();

            if (LavishScriptObject.IsNullOrInvalid(childWindow))
            {
                return;
            }

            childWindow.MakeActive();
        }
Exemplo n.º 27
0
        /// <summary>
        /// Get all skills our character knows.
        /// </summary>
        /// <returns></returns>
        public static List <Skill> GetSkills()
        {
            Me me = new Me();

            if (!LavishScriptObject.IsNullOrInvalid(me))
            {
                return(new Me().GetSkills());
            }

            return(new List <Skill>());
        }
Exemplo n.º 28
0
        /// <summary>
        /// Return a skill object based on the skill name parameter.
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static Skill GetSkill(string name)
        {
            Me me = new Me();

            if (!LavishScriptObject.IsNullOrInvalid(me))
            {
                return(new Me().Skill(name));
            }

            return(new Skill(null));
        }
Exemplo n.º 29
0
        public void InitializeCorporateHangars()
        {
            var inventoryWindow = _eveWindowProvider.GetInventoryWindow();
            var childWindow     = inventoryWindow.GetChildWindow(CurrentContainer.ID, "POSCorpHangars");

            if (LavishScriptObject.IsNullOrInvalid(childWindow))
            {
                LogMessage("InitializeCorporateHangars", LogSeverityTypes.Debug, "Error: No child window found for ID {0}, Name {1}.", CurrentContainer.ID, "POSCorpHangars");
                return;
            }

            childWindow.MakeActive();
        }
Exemplo n.º 30
0
        /// <summary>
        /// Translate an index of a given LavishScript type returned from the given method on the given object to a List of a .NET datatype equivalent.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="methodName"></param>
        /// <param name="lsTypeName"></param>
        /// <param name="args"></param>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static List <T> GetListFromMethod <T>(this ILSObject obj, string methodName, string lsTypeName, params string[] args)
        {
            //string methodName = "GetListFromMethod";
            //Tracing.SendCallback(methodName, MethodName, LSTypeName);

            if (obj == null || !obj.IsValid)
            {
                return(null);
            }

            //Tracing.SendCallback(methodName, "Create new LSO of index. Type: ", LSTypeName);
            using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName))
            {
                //Tracing.SendCallback(methodName, "Collapsing Args[]");

                string[] allargs;
                if (args.Length > 0)
                {
                    allargs = PrefixArray(index.LSReference, args);
                }
                else
                {
                    allargs    = new string[1];
                    allargs[0] = index.LSReference;
                }

                //Tracing.SendCallback(methodName, "Execute method, name: ", MethodName);
                if (!obj.ExecuteMethod(methodName, allargs))
                {
                    return(null);
                }

                //Tracing.SendCallback(methodName, "Get member Used");
                using (var used = index.GetMember("Used"))
                {
                    //Tracing.SendCallback(methodName, "LSO.IsNullOrInvalid (used)");
                    if (LavishScriptObject.IsNullOrInvalid(used))
                    {
                        return(null);
                    }
                }

                //Tracing.SendCallback(methodName, "IndexToList");
                var list = IndexToList <T>(index, lsTypeName);

                //Tracing.SendCallback(methodName, "Returning");
                return(list);
            }
        }