private bool moving;                                        //Used for pathing purposes.

        //The basic constructor of the class.
        public Ship(string template, StarSystem currentSystem, IntVec2 currentPosInSys)
        {
            rootTemplate            = ShipTemplateDict.GetTemplate(template);
            currentMovementSpeed    = rootTemplate.movementSpeed;
            remainingMovementPoints = rootTemplate.movementSpeed;
            hyperDriveIsFunctional  = true;
            this.currentSystem      = currentSystem;
            this.currentPosInSys    = currentPosInSys;
        }
        //Called upon starting by the Unity engine.
        void Start()
        {
            Settings.LoadSettings();                    //Loads the settings of the game.

            QualitySettings.vSyncCount = 60;            //Sets the frame rate cap used by Unity.

            StellarObjectTemplateDict.Initialize();     //Starts up all the crucial dictionaries we need.
            ShipTemplateDict.Initialize();
            MatDict.Initialize();

            StellarPathfinderList.Initialize();         //Starts up the list of StellarPathfinders.

            TemplateManager.BuildDicts();               //Orders the TemplateManager to build all the template dictionaries.

            DisplayManager.CreateDrawMesh();            //Order the DisplayManager to draw the mesh that is used for rendering.

            Galaxy.RandomGenerate(1, 1);                //Orders the Galaxy to randomly generate a 1 by 1 galaxy.

            //For testing purposes, add a simple ship object to the center of the only star system in the galaxy.
            Galaxy.galaxyArray[0, 0].systemObjects[15, 15].AddShip(new Ship("BasicShip", Galaxy.galaxyArray[0, 0], new IntVec2(15, 15)));
        }
        //Builds the ShipTemplate dictionary from the XML database.
        public static void BuildShipTemplateDict()
        {
            //Check that the dictionary hasn't already been built.
            if (!shipTemplateDictBuilt)
            {
                //First try to read ShipDefs.xml
                try
                {
                    reader = new XmlTextReader("Assets/Resources/Defs/ShipDefs.xml");
                }
                catch
                {
                    //Catch the file not being found.
                    Debug.Log("Could not find ShipDefs.xml");
                    return;
                }

                //Read until the end of the file.
                while (reader.Read())
                {
                    //Check if the element is a start element.
                    if (reader.IsStartElement())
                    {
                        //If it is, determine what variable it's referring to, and assign it.
                        switch (reader.Name.ToString())
                        {
                        //Begin a new ShipTemplate.
                        case "ShipTemplate":
                            workShipTemplate = new ShipTemplate();
                            break;

                        //Assign the graphicName to the template.
                        case "graphicName":
                            workShipTemplate.SetGraphicName(reader.ReadString());
                            break;

                        //Build the material for the template and then add it to the material dictionary.
                        case "graphicPath":
                            workMat                        = new Material(Shader.Find("Sprites/Default"));
                            workMat.mainTexture            = Resources.Load(reader.ReadString()) as Texture2D;
                            workMat.mainTexture.filterMode = FilterMode.Bilinear;
                            MatDict.SetMaterial(workShipTemplate.graphicName, workMat);
                            break;

                        //Assign the movementSpeed to the template.
                        case "movementSpeed":
                            workShipTemplate.SetMovementSpeed(int.Parse(reader.ReadString()));
                            break;
                        }
                    }
                    else
                    {
                        //Check if the node type is an end element.
                        if (reader.NodeType == XmlNodeType.EndElement)
                        {
                            //If it is, is this the end of a template?
                            if (reader.Name.Equals("ShipTemplate"))
                            {
                                //Finalize the template and add it to the ShipTemplate dictionary.
                                workShipTemplate.Finalized();
                                ShipTemplateDict.SetTemplate(workShipTemplate.graphicName, workShipTemplate);
                            }
                        }
                    }
                }
                //Close the file after it's been read and mark the dictionary built.
                reader.Close();
                shipTemplateDictBuilt = true;
            }
            else
            {
                //Otherwise, the dictionary has already been built and something went wrong.
                Debug.Log("Attempting to build already built ShipTemplateDict.");
            }
        }