Example #1
0
        public void Dispose()
        {
            long     end      = Stopwatch.GetTimestamp();
            TimeSpan timespan = new TimeSpan(end - _start);

            StaticLog.WriteToLog(_name, $"{timespan.TotalMilliseconds:0.##########}ms", LogType.General);
        }
Example #2
0
        public static void Run()
        {
            if (_customConfigSet)
            {
                return;
            }
            _customConfigSet = true;

            _customUserIni = Load.ReadFileFromWorldStorage(ConfigConstants.ConfigFileName, typeof(UserSettings));
            if (string.IsNullOrEmpty(_customUserIni))
            {
                StaticLog.WriteToLog("GetCustomUserIni", "No custom settings found. Exporting vanilla settings.", LogType.General);
                ExportDefaultUserSettings.Run();
                return;
            }
            if (!MyIni.TryParse(_customUserIni))
            {
                StaticLog.WriteToLog("GetCustomUserIni", "Parse failed for custom user settings. Exporting vanilla settings.", LogType.General);
                ExportDefaultUserSettings.Run();
                return;
            }
            if (!MyIni.ContainsSection(ConfigConstants.SectionName))
            {
                StaticLog.WriteToLog("GetCustomUserIni", "User config did not contain the proper section. Exporting vanilla settings.", LogType.General);
                ExportDefaultUserSettings.Run();
                return;
            }
            ParseConfig();
        }
Example #3
0
 private void WriteProfiler(string caller, string message)
 {
     lock (_writeLocker)
     {
         StaticLog.WriteToLog(caller, message, LogType.Profiling);
     }
 }
Example #4
0
        public void Dispose()
        {
            long     end      = Stopwatch.GetTimestamp();
            TimeSpan timespan = new TimeSpan(end - _start);

            if (Settings.GeneralSettings.ProfilingEnabled)
            {
                StaticLog.WriteToLog(_name, $"{timespan.TotalMilliseconds:0.##########}ms", LogType.Profiling);
            }
        }
Example #5
0
        public static void PrintTerminalActions(IMyEntity block)
        {
            IMyTerminalBlock myTerminalBlock = block as IMyTerminalBlock;

            if (myTerminalBlock == null)
            {
                return;
            }
            List <ITerminalAction> results = new List <ITerminalAction>();

            myTerminalBlock.GetActions(results);
            foreach (ITerminalAction terminalAction in results)
            {
                StaticLog.WriteToLog("PrintTerminalActions", $"Actions: {terminalAction.Id} | {terminalAction.Name}", LogType.General);
            }
        }
Example #6
0
 private void WriteException(string caller, string message, bool showOnHud, int duration, string color)
 {
     StaticLog.WriteToLog($"{CompName}: {caller}", $"Exception! {message}", LogType.Exception, showOnHud, duration, color);
 }
Example #7
0
 public static void WriteToStaticLog(string caller, string message, LogType logType)
 {
     StaticLog.WriteToLog(caller, message, logType);
 }
Example #8
0
 private void WriteException(string caller, string message)
 {
     StaticLog.WriteToLog($"{_baseType}: {caller}", $"Exception! {message}", LogType.Exception);
 }
Example #9
0
 private void ExceptionLog(string caller, string message)
 {
     StaticLog.WriteToLog($"{EntityName} ({EntityId}): {caller}", $"Exception! {message}", LogType.Exception);
 }
Example #10
0
 private void GeneralLog(string caller, string message)
 {
     StaticLog.WriteToLog($"{EntityName} ({EntityId}): {caller}", message, LogType.General);
 }
 private void DebugLog(string caller, string message)
 {
     StaticLog.WriteToLog($"{EntityName} ({EntityId}): {caller}", message, LogType.Debug);
 }
Example #12
0
        private static void ClassifySpawnGroups()
        {
            foreach (MySpawnGroupDefinition spawnGroupDefinition in MyDefinitionManager.Static.GetSpawnGroupDefinitions())
            {
                try
                {
                    if (spawnGroupDefinition == null)
                    {
                        continue;
                    }
                    if (!spawnGroupDefinition.Public)
                    {
                        continue;
                    }
                    if (spawnGroupDefinition.Prefabs == null || spawnGroupDefinition.Prefabs.Count == 0)
                    {
                        continue;
                    }
                    PrefabType type = spawnGroupDefinition.IsEncounter ? PrefabType.Encounter :
                                      spawnGroupDefinition.IsCargoShip ? PrefabType.CargoShip :
                                      (!spawnGroupDefinition.IsEncounter && !spawnGroupDefinition.IsPirate) ? PrefabType.CargoShip :
                                      PrefabType.None;
                    if (type == PrefabType.None)
                    {
                        continue;
                    }
                    string spawnGroupName = spawnGroupDefinition.Id.SubtypeName;
                    if (string.IsNullOrEmpty(spawnGroupName))
                    {
                        spawnGroupName = "wasNullOrEmpty";
                    }
                    string mod = string.IsNullOrEmpty(spawnGroupDefinition.Context.ModName) ? "Vanilla" : spawnGroupDefinition.Context.ModName;

                    foreach (MySpawnGroupDefinition.SpawnGroupPrefab prefab in spawnGroupDefinition.Prefabs.AsReadOnly())
                    {
                        MyPrefabDefinition prefabDef = MyDefinitionManager.Static.GetPrefabDefinition(prefab.SubtypeId);
                        if (prefabDef == null)
                        {
                            continue;
                        }
                        if (prefabDef.CubeGrids.Length == 0)
                        {
                            continue;
                        }
                        if (!prefabDef.Public)
                        {
                            continue;
                        }
                        string           name = prefabDef.CubeGrids[0].DisplayName;
                        SpawnGroupPrefab sgp  = new SpawnGroupPrefab(spawnGroupName, name, type, false, false, mod);
                        switch (type)
                        {
                        case PrefabType.Encounter:
                            if (EncounterPrefabs.ContainsKey(name))
                            {
                                continue;
                            }
                            EncounterPrefabs.Add(name, sgp);
                            continue;

                        case PrefabType.CargoShip:
                            if (CargoShipPrefabs.ContainsKey(name))
                            {
                                continue;
                            }
                            CargoShipPrefabs.Add(name, sgp);
                            continue;

                        case PrefabType.None:
                            continue;

                        case PrefabType.SubGrid:
                            continue;

                        default:
                            continue;
                        }
                    }
                }
                catch (Exception e)
                {
                    StaticLog.WriteToLog("ClassifySpawnGroups", e.ToString(), LogType.Exception);
                }
            }

            foreach (KeyValuePair <string, SpawnGroupPrefab> prefab in EncounterPrefabs)
            {
                StaticLog.WriteToLog("ClassifySpawnGroups-Encounter", $"{prefab.Value}", LogType.General);
            }

            foreach (KeyValuePair <string, SpawnGroupPrefab> prefab in CargoShipPrefabs)
            {
                StaticLog.WriteToLog("ClassifySpawnGroups-CargoShip", $"{prefab.Value}", LogType.General);
            }

            Ready = true;
        }