Exemplo n.º 1
0
        public void SaveStage(string filename)
        {
            worldFile = filename;

            //create an empty ParameterSet
            ParameterSet newParms = new ParameterSet();

            // add the asset name (world filename without extension)
            newParms.AddParm("AssetName", System.IO.Path.GetFileNameWithoutExtension(worldFile));

            if (parms.HasParm("SunAngles"))
                newParms.AddParm("SunAngles", parms.GetVector2("SunAngles")); // in need a better solution

            // add the quarterback list to the parm set
            string qbs = "";
            foreach (KeyValuePair<System.Type, Quarterback> qb in Stage.ActiveStage.QBTable)
            {
                //check if this is the first addition to the quarterbacks string
                qbs += qb.Value.Name() + ',';
            }

            qbs = qbs.Remove(qbs.Length - 1); // remove the last comma

            //add the qbs to the Quarterbacks key
            newParms.AddParm("Quarterbacks", qbs);

            foreach (KeyValuePair<System.Type, Quarterback> qb in Stage.ActiveStage.QBTable)
            {
                //serialize the current quarterback
                qb.Value.Serialize(newParms);
            }

            //set parms to newParms
            parms = newParms;

            //write file
            parms.ToFile(worldFile);
        }