コード例 #1
0
ファイル: Loader.cs プロジェクト: isxGames/StealthBot
        private static bool IsMinimumIsxeveVersionLoaded()
        {
            string isxeveVersion = null;

            try
            {
                LavishScript.DataParse("${ISXEVE.Version}", ref isxeveVersion);
            }
            catch (Exception)
            {
                isxeveVersion = null;
            }

            if (string.IsNullOrEmpty(isxeveVersion))
            {
                return(false);
            }

            var fragments = isxeveVersion.Split('.');

            if (fragments.Length != 2)
            {
                return(false);
            }

            var dateString    = fragments[0];
            var versionString = fragments[1];

            DateTime?date;

            try
            {
                date = DateTime.ParseExact(dateString, "yyyyMMdd", null);
            }
            catch (FormatException)
            {
                return(false);
            }

            int version;

            if (!int.TryParse(versionString, out version))
            {
                return(false);
            }

            if (date > _minimumIsxeveVersionDate)
            {
                return(true);
            }

            if (date == _minimumIsxeveVersionDate && version >= _minimumIsxeveVersionBuild)
            {
                return(true);
            }

            return(false);
        }
コード例 #2
0
ファイル: Loader.cs プロジェクト: isxGames/StealthBot
        private static bool IsIsxeveLoaded()
        {
            var isxEveLoaded = false;

            try
            {
                LavishScript.DataParse("${ISXEVE(exists)}", ref isxEveLoaded);
            }
            catch { }

            return(isxEveLoaded);
        }
コード例 #3
0
        /// <summary>
        /// Signal to listeners that they need to update a configuration file reference.
        /// </summary>
        /// <param name="oldFileName"></param>
        /// <param name="newFileName"></param>
        public void Send_SB_Event_Notify_UpdateConfigurationFile(string oldFileName, string newFileName)
        {
            string methodName = "Send_Notify_UpdateConfigurationFile";

            Core.StealthBot.Logging.OnLogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
                                                                              methodName, string.Empty));

            string uplinkName = string.Empty;

            LavishScript.DataParse <string>("${SettingXML[InnerSpace.XML].Set[Remote].GetString[Name].Escape}", ref uplinkName);
            string eventString = String.Format("relay \"other {0}\" \"Event[{1}]:Execute[{2},{3},{4}]\"",
                                               RelayGroup, SB_Events.SB_Event_Notify_UpdateConfigurationFile.ToString(),
                                               uplinkName, oldFileName, newFileName);

            Core.StealthBot.Logging.OnLogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Minor,
                                                                              methodName, String.Format("Sending {0}", eventString)));
            LavishScript.ExecuteCommand(eventString);
        }
コード例 #4
0
        private void _handle_SB_Event_Notify_UpdateConfigurationFile(object sender, LSEventArgs e)
        {
            string methodName = "_handle_Notify_UpdateConfigurationFile";

            Core.StealthBot.Logging.OnLogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
                                                                              methodName, string.Empty));
            Notify_UpdateConfigurationFileEventArgs eventArgs = new Notify_UpdateConfigurationFileEventArgs(e);

            Core.StealthBot.Logging.OnLogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Minor,
                                                                              methodName, "Received UpdateConfigurationFile"));
            //Make sure we're on our uplink
            string uplinkName = string.Empty;

            LavishScript.DataParse <string>("${SettingXML[InnerSpace.XML].Set[Remote].GetString[Name].Escape}", ref uplinkName);
            if (uplinkName == eventArgs.UplinkName &&
                OnSB_Event_Notify_UpdateConfigurationFile != null)
            {
                OnSB_Event_Notify_UpdateConfigurationFile(this, eventArgs);
            }
        }
コード例 #5
0
        private void HandlePulse()
        {
            var methodName = "HandlePulse";

            LogTrace(methodName);

            //Do any critical pulses
            foreach (var module in Modules)
            {
                module.CriticalPulse();
            }

            LavishScript.DataParse("${SettingXML[InnerSpace.XML].Set[Remote].GetString[Name].Escape}", ref _uplinkName);

            //Process critically-blocking modules
            var isAnyModuleBlocking = CriticallyBlockingModules.Any(blockingModule => blockingModule.CriticallyBlock());

            if (isAnyModuleBlocking)
            {
                return;
            }

            //First, pulse the Cache modules
            foreach (var module in CachesToPulse)
            {
                //StartMethodProfiling(string.Format("Pulse {0}", module.ObjectName));
                TryPulseModule(module);
                //EndMethodProfiling();
            }

            //Return if EVE, MyShip are invalid and not InSpace but not InStation
            if (!StealthBot.MeCache.InSpace && !StealthBot.MeCache.InStation)
            {
                LogMessage(methodName, LogSeverityTypes.Debug, "Ending pulse due to some form of loading or break (not InSpace and not InStation).");
                return;
            }

            //Do any important actions, i.e. toggling UI/3d display or closing chats
            //StartMethodProfiling("Important Pulse Actions");
            HandleImportantPulseActions();
            //EndMethodProfiling();

            //If we're just supposed to load a config and not actually pulse things, return.
            if (StealthBot.JustLoadConfig)
            {
                return;
            }

            //If we're not initialized yet, initialize
            if (!IsInitialized)
            {
                IsInitialized = Initialize();
                return;
            }

            //Now pulse Entity caches
            foreach (var module in EntityCachesToPulse)
            {
                //StartMethodProfiling(string.Format("Pulse {0}", module.ObjectName));
                TryPulseModule(module);
                //EndMethodProfiling();
            }

            //up next, actual core modules
            foreach (var module in ModulesToPulse)
            {
                //StartMethodProfiling(string.Format("Pulse {0}", module.ObjectName));
                TryPulseModule(module);
                //EndMethodProfiling();
            }

            //Separately pulse the SbUiCommunication module
            //StartMethodProfiling("SbUiCommunication");
            //TryPulseModule(StealthBot.SbUiCommunication);
            //EndMethodProfiling();
        }
コード例 #6
0
        private void SendStateObject()
        {
            var methodName = "SendStateObject";

            LogTrace(methodName);

            //Parse out the session name
            var sessionName = string.Empty;

            LavishScript.DataParse("${Session}", ref sessionName);

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Post-Session"));

            //Build and send the state object
            //Get our ship type if we can, otherwise just use the typeID
            var shipType = string.Empty;

            shipType = Enum.IsDefined(typeof(TypeIDs), StealthBot.MeCache.ToEntity.TypeId) ?
                       ((TypeIDs)StealthBot.MeCache.ToEntity.TypeId).ToString() : StealthBot.MeCache.ToEntity.TypeId.ToString();

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Ship type"));

            //Instantiate a new state object to work with
            var stateObject = new SbStateObject(
                sessionName, StealthBot.MeCache.Name, false, StealthBot.MeCache.Ship.ShieldPct, StealthBot.MeCache.Ship.ArmorPct,
                StealthBot.MeCache.Ship.StructurePct, StealthBot.MeCache.Ship.CapacitorPct, StealthBot.MeCache.Ship.Name,
                shipType, StealthBot.Instance.RunTime.Elapsed.ToString());

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Post-instantiate"));

            //Get recent log messages

            /*List<string> recentMessages;
             * lock (Core.StealthBot.Logging.RecentMessages)
             * {
             *  recentMessages = new List<string>(Core.StealthBot.Logging.RecentMessages);
             *  Core.StealthBot.Logging.RecentMessages.Clear();
             * }
             * stateObject.LogMessages = recentMessages;
             */

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Recent messages"));

            //Get asteroids in range
            stateObject.AsteroidsInRange = new List <string>();
            foreach (var asteroid in StealthBot.AsteroidBelts.AsteroidsInRange)
            {
                stateObject.AsteroidsInRange.Add(string.Format("{0} {1} {2}", asteroid.Distance, asteroid.Name, asteroid.ID));
            }

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Asteroids in range"));

            //Get asteroids out of range
            stateObject.AsteroidsOutOfRange = new List <string>();
            foreach (var asteroid in StealthBot.AsteroidBelts.AsteroidsOutOfRange)
            {
                stateObject.AsteroidsOutOfRange.Add(string.Format("{0} {1} {2}", asteroid.Distance, asteroid.Name, asteroid.ID));
            }

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Asteroids out of range"));

            //Get everything in the target queue
            stateObject.QueuedTargets = new List <string>();
            foreach (var queueTarget in StealthBot.TargetQueue.Targets)
            {
                if (StealthBot.EntityProvider.EntityWrappersById.ContainsKey(queueTarget.Id))
                {
                    var entity = Core.StealthBot.EntityProvider.EntityWrappersById[queueTarget.Id];
                    stateObject.QueuedTargets.Add(string.Format("{0} {1} {2} {3} {4}", entity.Distance, entity.Name, entity.ID,
                                                                queueTarget.Priority, queueTarget.SubPriority));
                }
                else
                {
                    stateObject.QueuedTargets.Add(string.Format("{0} - Invalid Entity", queueTarget.Id));
                }
            }

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Queued targets"));

            //Get all locked targets
            stateObject.LockedTargets = new List <string>();
            foreach (var entity in StealthBot.MeCache.Targets)
            {
                stateObject.LockedTargets.Add(string.Format("{0} {1} {2}", entity.Distance, entity.Name, entity.ID));
            }

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "Entities"));

            //Get everything in the destination queue
            stateObject.DestinationQueue = new List <string>();
            foreach (var destination in StealthBot.Movement.DestinationQueue)
            {
                var formattedString = destination.Type.ToString();
                switch (destination.Type)
                {
                case DestinationTypes.BookMark:
                    formattedString = string.Format("{0} {1} {2}", formattedString, destination.BookMarkId, destination.SolarSystemId);
                    break;

                case DestinationTypes.Celestial:
                    var entityName = "NOT ON GRID";
                    if (Core.StealthBot.EntityProvider.EntityWrappersById.ContainsKey(destination.EntityId))
                    {
                        entityName = StealthBot.EntityProvider.EntityWrappersById[destination.EntityId].Name;
                    }
                    formattedString = string.Format("{0} {1} {2} {3}", formattedString, entityName, destination.EntityId, destination.Distance);
                    break;

                case DestinationTypes.Entity:
                    goto case DestinationTypes.Celestial;

                case DestinationTypes.FleetMember:
                    formattedString = string.Format("{0} {1} {2} {3}", formattedString, destination.FleetMemberName, destination.FleetMemberId,
                                                    destination.FleetMemberEntityId);
                    break;

                case DestinationTypes.SolarSystem:
                    formattedString = string.Format("{0} {1}", formattedString, destination.SolarSystemId);
                    break;

                case DestinationTypes.Undock:
                    formattedString = string.Format("{0} Undock", formattedString);
                    break;
                }
                stateObject.DestinationQueue.Add(formattedString);
            }

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "desti queue"));

            //Get all threats
            stateObject.Threats = new List <string>();
            foreach (var entity in StealthBot.Attackers.ThreatEntities)
            {
                stateObject.Threats.Add(string.Format("{0} {1} {2}", entity.Distance, entity.Name, entity.ID));
            }

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "threats"));

            //Get statistical data
            stateObject.ItemsMined_Moved  = new Dictionary <string, int>(StealthBot.Statistics.MinedItemsMovedByItemName);
            stateObject.Ammo_CrystalsUsed = new Dictionary <string, int>(StealthBot.Statistics.QuantityChargesUsedByName);

            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "dicts"));

            //Send configuration profiles too
            stateObject.ConfigurationProfiles = new Dictionary <string, Dictionary <string, ConfigProperty> >(StealthBot.ConfigurationManager.ConfigProfilesByName);

            //Transmit the state object we've built
            _sbIpcClient.SendSbStateObject(stateObject);
            //Core.StealthBot.Logging.LogMessage(ObjectName, new LogEventArgs(LogSeverityTypes.Trace,
            //methodName, "send"));
        }