Artemis.Engine.GameConstants.Read C# (CSharp) Method

Read() public method

Read the Game constants file.
public Read ( string fileName ) : void
fileName string
return void
        public void Read(string fileName)
        {
            var doc = new XmlDocument();
            try
            {
                doc.Load(fileName);
            }
            catch (IOException)
            {
                return;
            }

            var root = doc.ChildNodes[1] as XmlElement;
            if (root.Name != XmlElements.ROOT)
            {
                // Should we throw an error or log something, or just fail silently?
                return;
            }
            foreach (var child in root.ChildNodes)
            {
                var element = child as XmlElement;
                if (element == null)
                    continue;

                switch (element.Name)
                {
                    case XmlElements.KERNEL_CONSTANTS:
                        ReadElements(element, kernelConstantReaders);
                        break;
                    case XmlElements.DISPLAY_CONSTANTS:
                        ReadElements(element, displayConstantReaders);
                        break;
                    case XmlElements.OPTION_DEFAULT_CONSTANTS:
                        ReadElements(element, optionDefaultsConstantReaders);
                        break;
                    case XmlElements.PHYSICS_CONSTANTS:
                        ReadElements(element, physicsConstantReaders);
                        break;
                    case XmlElements.DEBUG_CONSTANTS:
                        ReadElements(element, debugConstantReaders);
                        break;
                    default:
                        continue;
                }
            }
        }

Usage Example

Esempio n. 1
0
 internal static void ReadFromFile(string fileName)
 {
     Instance.Read(fileName);
 }