Exemple #1
0
        public ShipHullRessources(SSDirectory directory, VariantsRessources variantsResources)
        {
            Directory          = directory;
            VariantsRessources = variantsResources;

            RefreshRessource();
        }
Exemple #2
0
        public void ExtractHullIdUsedFromVariant()
        {
            Directory.GroupedFiles.TryGetValue("data\\world\\factions\\default_ship_roles.json", out ISSGroup roleGroup);
            SSJsonGroup jsonRoleGroup = (SSJsonGroup)roleGroup;

            if (jsonRoleGroup == null)
            {
                return;
            }
            if (jsonRoleGroup.MonitoredContent == null)
            {
                jsonRoleGroup.ExtractMonitoredContent();
            }
            List <string> referencedShipVariant = new List <string>();

            foreach (string role in ShipRoles)
            {
                jsonRoleGroup.MonitoredContent.MonitoredProperties.TryGetValue(new JsonValue(role), out MonitoredField FieldVariantList);
                if (FieldVariantList is MonitoredObject shipList)
                {
                    referencedShipVariant.AddRange(shipList.MonitoredProperties.Where(x => x.Value is MonitoredValue).Select(x => x.Key.ToString()));
                }
                else
                {
                    throw new Exception("Default ship role contains non object field with expected name");
                }
            }
            ReferencedShipHullIdFromVariant = referencedShipVariant.Distinct().Select(x => VariantsRessources.GetHullIdFromVariantName(x)).Distinct().ToList();
        }