Ejemplo n.º 1
0
 private DynamicFlag(IConnection connection, IDispatcher dispatcher, IEnumerable <string> names, Delegate parser, T defaultValue)
 {
     _logger       = Logger.DefaultWithName("DynamicFlag " + string.Concat(names));
     _names        = new SortedSet <string>(names);
     _parser       = parser;
     _defaultValue = defaultValue;
     _value        = defaultValue;
     dispatcher.OnFlagUpdate(OnFlagUpdate);
     if (connection != null)
     {
         AttachConnection(connection);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Create a new CimToolBase with your mod settings. This will create
        /// instances of useful tools and you can access them from this class.
        /// </summary>
        /// <param name="modSettings">Your mod settings</param>
        public CimToolBase(CimToolSettings modSettings)
        {
            m_modSettings = modSettings;

            m_spriteUtilities = new SpriteUtilities();
            m_uiUtilities     = new UIUtilities();
            m_strings         = new Strings(this);
            m_path            = new Path(this);
            m_version         = new Version(this);
            m_detailedLogger  = new DetailedLogger(this);
            m_namedLogger     = new NamedLogger(this);
            m_translation     = new Translation(this);
            m_xmlOptions      = new XmlFileManager(this);
            m_saveFileOptions = new SaveFileManager(this);
            m_changelog       = new Changelog(this);
            m_modOptions      = new ModOptionPanelUtilities(this);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Constructs a MovingAverage object with the specified period with a flag to control logging
        /// </summary>
        /// <param name="sampleCount">Moving average period</param>
        /// <param name="log">Whether to log data</param>
        public MovingAverage(int sampleCount, bool log = false)
        {
            SampleCount = sampleCount;
            Samples     = new UserData[SampleCount];

            this.log = log;

            if (log)
            {
                nLog = new NamedLogger(
                    new Dictionary <string, string> {
                    { "raLogRaw", "raLogRaw" },
                    { "raAvLog", "raAvLog" }
                },
                    log, Path.Combine(Application.dataPath, "UserData", "Logs"));

                disList.Add(nLog);
            }
        }
        public static void MaybeFailFast(string origin, FormattableString msg, Exception ex)
        {
            var logger = new NamedLogger(origin, MyLog.Default);

            logger.Critical(msg);
            logger.Critical(ex);
            // ReSharper disable once InvertIf
            if (FailFast)
            {
                MyLog.Default?.Flush();
                throw ex;
            }

            var utils = ((IMyUtilities)MyAPIUtilities.Static);

            if (!utils.IsDedicated && (!_errorDebounce.HasValue || DateTime.UtcNow > _errorDebounce.Value + TimeSpan.FromMinutes(5)))
            {
                utils.ShowNotification("An error occurred.  Please submit your logs to Equinox",
                                       textColor: new Vector4(1, 0, 0, 1));
                _errorDebounce = DateTime.UtcNow;
            }
        }
Ejemplo n.º 5
0
    /// <summary>
    /// Initialize tracking system. Called once on game startup.
    /// </summary>
    void Start()
    {
        av = new MovingAverage(averagingSamples, logTrackingData);
        disList.Add(av);

        var logPath = Path.Combine(Application.dataPath, "Logs");

        // Create Logger
        nLog = new NamedLogger(
            new Dictionary <string, string> {
            { "rAngle", "rAngle" },
            { "lAngle", "lAngle" },
            { "rElev", "rElev" },
            { "rHorizX", "rHorizX" },
            { "rHorizZ", "rHorizZ" }
        },
            logTrackingData, logPath);

        // Add logger to list of objects to dispose of
        disList.Add(nLog);


        sk = new Skelly(maxJointVelocity, true);
    }
            public VoxelPlacementDefinition(MyObjectBuilder_VoxelMiningDefinition.MiningDef ob, NamedLogger log)
            {
                Material = MyDefinitionManager.Get <MyVoxelMaterialDefinition>(ob.VoxelMaterial);
                if (Material == null)
                {
                    log.Warning($"Could not find voxel material definition {ob.VoxelMaterial}");
                    Material = MyVoxelMaterialDefinition.Default;
                }

                Volume = ob.VolumeAttribute;
                var replacementItems = new Dictionary <MyDefinitionId, int>();

                foreach (var item in ob.MinedItems)
                {
                    MyObjectBuilderType type;
                    try
                    {
                        type = MyObjectBuilderType.Parse(item.Type);
                    }
                    catch
                    {
                        log.Warning($"Can not parse defined builder type {item.Type}");
                        continue;
                    }

                    var key = new MyDefinitionId(type, MyStringHash.GetOrCompute(item.Subtype));
                    replacementItems[key] = item.Amount;
                }

                Items = replacementItems;
            }