Beispiel #1
0
        public static void GenerateNewModFile()
        {
            var defaultModFile = new ModControlStructure();

            defaultModFile.SetDefaultAllowedParts();
            defaultModFile.SetDefaultAllowedResources();

            FileHandler.WriteToFile(ServerContext.ModFilePath, LunaXmlSerializer.SerializeToXml(defaultModFile));
        }
Beispiel #2
0
        public void CheckCommonStockParts()
        {
            var missingPartsCount     = 0;
            var missingResourcesCount = 0;
            var modFile = new ModControlStructure();

            modFile.SetDefaultAllowedParts();
            modFile.SetDefaultAllowedResources();

            LunaLog.Log("[LMP]: Missing parts start");
            foreach (var part in PartLoader.LoadedPartsList.Where(p => !modFile.AllowedParts.Contains(p.name)))
            {
                missingPartsCount++;
                LunaLog.Log($"[LMP]: Missing part: '{part.name}'");
            }
            LunaLog.Log("[LMP]: Missing parts end");

            LunaLog.Log("[LMP]: Missing resources start");
            foreach (var resource in PartResourceLibrary.Instance.resourceDefinitions.Cast <PartResourceDefinition>().Select(r => r.name)
                     .Where(r => !modFile.AllowedResources.Contains(r)))
            {
                missingResourcesCount++;
                LunaLog.Log($"[LMP]: Missing resource: '{resource}'");
            }
            LunaLog.Log("[LMP]: Missing resources end");

            if (missingPartsCount > 0 && missingResourcesCount <= 0)
            {
                LunaScreenMsg.PostScreenMessage($"{missingPartsCount} missing part(s) from Common.dll printed to log ({PartLoader.LoadedPartsList.Count} total)",
                                                5f, ScreenMessageStyle.UPPER_CENTER);
            }
            else if (missingPartsCount <= 0 && missingResourcesCount <= 0)
            {
                LunaScreenMsg.PostScreenMessage("No missing parts/resources from Common.dll", 5f, ScreenMessageStyle.UPPER_CENTER);
            }
            else if (missingPartsCount <= 0 && missingResourcesCount > 0)
            {
                LunaScreenMsg.PostScreenMessage($"{missingResourcesCount} missing resources from Common.dll printed to log ({PartResourceLibrary.Instance.resourceDefinitions.Count} total)", 5f, ScreenMessageStyle.UPPER_CENTER);
            }
            else
            {
                LunaScreenMsg.PostScreenMessage($"{missingPartsCount} missing part(s) from Common.dll printed to log ({PartLoader.LoadedPartsList.Count} total). " +
                                                $"{missingResourcesCount} missing resources from Common.dll printed to log ({PartResourceLibrary.Instance.resourceDefinitions.Count} total)",
                                                5f, ScreenMessageStyle.UPPER_CENTER);
            }
        }