Beispiel #1
0
        public SubmarineInfo(SubmarineInfo original)
        {
            Name                      = original.Name;
            DisplayName               = original.DisplayName;
            Description               = original.Description;
            Price                     = original.Price;
            InitialSuppliesSpawned    = original.InitialSuppliesSpawned;
            GameVersion               = original.GameVersion;
            Type                      = original.Type;
            SubmarineClass            = original.SubmarineClass;
            hash                      = !string.IsNullOrEmpty(original.FilePath) ? original.MD5Hash : null;
            Dimensions                = original.Dimensions;
            FilePath                  = original.FilePath;
            RequiredContentPackages   = new HashSet <string>(original.RequiredContentPackages);
            IsFileCorrupted           = original.IsFileCorrupted;
            SubmarineElement          = original.SubmarineElement;
            EqualityCheckVal          = original.EqualityCheckVal;
            RecommendedCrewExperience = original.RecommendedCrewExperience;
            RecommendedCrewSizeMin    = original.RecommendedCrewSizeMin;
            RecommendedCrewSizeMax    = original.RecommendedCrewSizeMax;
            Tags                      = original.Tags;
            if (original.OutpostModuleInfo != null)
            {
                OutpostModuleInfo = new OutpostModuleInfo(original.OutpostModuleInfo);
            }
#if CLIENT
            PreviewImage = original.PreviewImage != null ? new Sprite(original.PreviewImage) : null;
#endif
        }
Beispiel #2
0
        private void Init()
        {
            DisplayName = TextManager.Get("Submarine.Name." + Name, true);
            if (string.IsNullOrEmpty(DisplayName))
            {
                DisplayName = Name;
            }

            Description = TextManager.Get("Submarine.Description." + Name, true);
            if (string.IsNullOrEmpty(Description))
            {
                Description = SubmarineElement.GetAttributeString("description", "");
            }

            EqualityCheckVal = SubmarineElement.GetAttributeInt("checkval", 0);

            Price = SubmarineElement.GetAttributeInt("price", 1000);

            InitialSuppliesSpawned = SubmarineElement.GetAttributeBool("initialsuppliesspawned", false);

            GameVersion = new Version(SubmarineElement.GetAttributeString("gameversion", "0.0.0.0"));
            if (Enum.TryParse(SubmarineElement.GetAttributeString("tags", ""), out SubmarineTag tags))
            {
                Tags = tags;
            }
            Dimensions                = SubmarineElement.GetAttributeVector2("dimensions", Vector2.Zero);
            RecommendedCrewSizeMin    = SubmarineElement.GetAttributeInt("recommendedcrewsizemin", 0);
            RecommendedCrewSizeMax    = SubmarineElement.GetAttributeInt("recommendedcrewsizemax", 0);
            RecommendedCrewExperience = SubmarineElement.GetAttributeString("recommendedcrewexperience", "Unknown");

            if (SubmarineElement?.Attribute("type") != null)
            {
                if (Enum.TryParse(SubmarineElement.GetAttributeString("type", ""), out SubmarineType type))
                {
                    Type = type;
                    if (Type == SubmarineType.OutpostModule)
                    {
                        OutpostModuleInfo = new OutpostModuleInfo(this, SubmarineElement);
                    }
                }
            }

            if (Type == SubmarineType.Player)
            {
                if (SubmarineElement?.Attribute("class") != null)
                {
                    if (Enum.TryParse(SubmarineElement.GetAttributeString("class", "Undefined"), out SubmarineClass submarineClass))
                    {
                        SubmarineClass = submarineClass;
                    }
                }
            }
            else
            {
                SubmarineClass = SubmarineClass.Undefined;
            }

            //backwards compatibility (use text tags instead of the actual text)
            if (RecommendedCrewExperience == "Beginner")
            {
                RecommendedCrewExperience = "CrewExperienceLow";
            }
            else if (RecommendedCrewExperience == "Intermediate")
            {
                RecommendedCrewExperience = "CrewExperienceMid";
            }
            else if (RecommendedCrewExperience == "Experienced")
            {
                RecommendedCrewExperience = "CrewExperienceHigh";
            }

            RequiredContentPackages.Clear();
            string[] contentPackageNames = SubmarineElement.GetAttributeStringArray("requiredcontentpackages", new string[0]);
            foreach (string contentPackageName in contentPackageNames)
            {
                RequiredContentPackages.Add(contentPackageName);
            }

            InitProjectSpecific();
        }