Ejemplo n.º 1
0
        public TalentPrefab(XElement element, string filePath)
        {
            FilePath      = filePath;
            ConfigElement = element;
            Identifier    = element.GetAttributeString("identifier", "noidentifier");
            DisplayName   = TextManager.Get("talentname." + Identifier, returnNull: true) ?? Identifier;
            this.CalculatePrefabUIntIdentifier(TalentPrefabs);

            foreach (XElement subElement in element.Elements())
            {
                switch (subElement.Name.ToString().ToLowerInvariant())
                {
                case "icon":
                    Icon = new Sprite(subElement);
                    break;

                case "description":
                    string tempDescription = Description;
                    TextManager.ConstructDescription(ref tempDescription, subElement);
                    Description = tempDescription;
                    break;
                }
            }

            if (string.IsNullOrEmpty(Description))
            {
                if (element.Attribute("description") != null)
                {
                    string description = element.GetAttributeString("description", string.Empty);
                    Description = TextManager.Get(description, returnNull: true) ?? description;
                }
                else
                {
                    Description = TextManager.Get("talentdescription." + Identifier, returnNull: true) ?? string.Empty;
                }
            }

#if DEBUG
            if (!TextManager.ContainsTag("talentname." + Identifier))
            {
                DebugConsole.AddWarning($"Name for the talent \"{Identifier}\" not found in the text files.");
            }
            if (string.IsNullOrEmpty(Description))
            {
                DebugConsole.AddWarning($"Description for the talent \"{Identifier}\" not configured");
            }
            if (Description.Contains('['))
            {
                DebugConsole.ThrowError($"Description for the talent \"{Identifier}\" contains brackets - was some variable not replaced correctly? ({Description})");
            }
#endif
        }