コード例 #1
0
ファイル: CubeGrid.cs プロジェクト: elidiak/SpaceEditor
        public CubeBlock loadXMLFragment(string xml)
        {
            NameTable           nt    = new NameTable();
            XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);

            nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
            XmlParserContext  context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
            XmlReaderSettings xset    = new XmlReaderSettings();

            xset.ConformanceLevel = ConformanceLevel.Fragment;
            XmlReader   rd     = XmlReader.Create(new StringReader(xml), xset, context);
            XmlDocument NewDoc = new XmlDocument();

            NewDoc.Load(rd);
            CubeBlock cb = new CubeBlock(this.parent_sector);

            cb.loadFromXML(NewDoc.SelectSingleNode("MyObjectBuilder_CubeBlock"));
            cb.new_id();
            return(cb);
        }
コード例 #2
0
ファイル: CubeGrid.cs プロジェクト: elidiak/SpaceEditor
        public void loadFromXML(XmlNode node, bool quick = false)
        {
            base.loadFromXML(node);
            this.GridSizeEnum = node.SelectSingleNode("GridSizeEnum").InnerText;
            this.quick_loaded = quick;
            XmlNodeList blocks = node.SelectNodes("CubeBlocks/MyObjectBuilder_CubeBlock");

            if (quick == false)
            {
                Console.WriteLine("Loading blocks...");
                foreach (XmlNode block in blocks)
                {
                    CubeBlock new_block = new CubeBlock(this.parent_sector);
                    new_block.loadFromXML(block);
                    if (new_block.SubTypeName == "LargeBlockCockpit" || new_block.SubTypeName == "SmallBlockCockpit")
                    {
                        this.cockpit = new_block;
                        if (new_block.hasPilot == true)
                        {
                            Console.WriteLine("Grid has pilot");
                            this.hasPilot          = true;
                            new_block.Pilot.parent = this.EntityId;
                            this.Pilot             = new_block.Pilot;
                        }
                    }
                    CubeBlocks.Add(new_block);
                }
            }
            else
            {
                this.raw = node.SelectSingleNode("CubeBlocks").OuterXml;
                Console.WriteLine("Quick loaded");
                this.quick_count = blocks.Count;
            }
            try
            {
                IsStatic = node.SelectSingleNode("IsStatic").InnerText;
                LinearVelocity.loadFromXML(node.SelectSingleNode("LinearVelocity"));
                AngularVelocity.loadFromXML(node.SelectSingleNode("AngularVelocity"));
            }
            catch (NullReferenceException) { }
            if (this.GridSizeEnum == "Large")
            {
                if (this.IsStatic == "true")
                {
                    this.displayType = "Station";
                }
                else
                {
                    this.displayType = "Large Ship";
                }
            }
            if (this.GridSizeEnum == "Small")
            {
                this.displayType = "Small Ship";
            }
            if (this.hasPilot == true)
            {
                this.displayType = "[*] " + this.displayType;
            }
            this.actualType = "Ship";
            Console.WriteLine("Loaded");
            //Console.WriteLine("Loaded "+displayType+" with "+CubeBlocks.Count +" blocks");
        }
コード例 #3
0
ファイル: CubeGrid.cs プロジェクト: Tall-Paul/SpaceEditor
 public CubeBlock loadXMLFragment(string xml)
 {
     NameTable nt = new NameTable();
     XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt);
     nsmgr.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
     XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None);
     XmlReaderSettings xset = new XmlReaderSettings();
     xset.ConformanceLevel = ConformanceLevel.Fragment;
     XmlReader rd = XmlReader.Create(new StringReader(xml), xset, context);
     XmlDocument NewDoc = new XmlDocument();
     NewDoc.Load(rd);
     CubeBlock cb = new CubeBlock(this.parent_sector);
     cb.loadFromXML(NewDoc.SelectSingleNode("MyObjectBuilder_CubeBlock"));
     cb.new_id();
     return cb;
 }
コード例 #4
0
ファイル: CubeGrid.cs プロジェクト: Tall-Paul/SpaceEditor
 public void loadFromXML(XmlNode node, bool quick = false)
 {
     base.loadFromXML(node);
     this.GridSizeEnum = node.SelectSingleNode("GridSizeEnum").InnerText;
     this.quick_loaded = quick;
     XmlNodeList blocks = node.SelectNodes("CubeBlocks/MyObjectBuilder_CubeBlock");
     if (quick == false)
     {
         Console.WriteLine("Loading blocks...");
         foreach (XmlNode block in blocks)
         {
             CubeBlock new_block = new CubeBlock(this.parent_sector);
             new_block.loadFromXML(block);
             if (new_block.SubTypeName == "LargeBlockCockpit" || new_block.SubTypeName == "SmallBlockCockpit")
             {
                 this.cockpit = new_block;
                 if (new_block.hasPilot == true)
                 {
                     Console.WriteLine("Grid has pilot");
                     this.hasPilot = true;
                     new_block.Pilot.parent = this.EntityId;
                     this.Pilot = new_block.Pilot;
                 }
             }
             CubeBlocks.Add(new_block);
         }
     }
     else
     {
         this.raw = node.SelectSingleNode("CubeBlocks").OuterXml;
         Console.WriteLine("Quick loaded");
         this.quick_count = blocks.Count;
     }
     try
     {
         IsStatic = node.SelectSingleNode("IsStatic").InnerText;
         LinearVelocity.loadFromXML(node.SelectSingleNode("LinearVelocity"));
         AngularVelocity.loadFromXML(node.SelectSingleNode("AngularVelocity"));
     }
     catch (NullReferenceException) { }
     if (this.GridSizeEnum == "Large")
         if (this.IsStatic == "true")
             this.displayType = "Station";
         else
             this.displayType = "Large Ship";
     if (this.GridSizeEnum == "Small")
         this.displayType = "Small Ship";
     if (this.hasPilot == true)
     {
         this.displayType = "[*] " + this.displayType;
     }
     this.actualType = "Ship";
     Console.WriteLine("Loaded");
     //Console.WriteLine("Loaded "+displayType+" with "+CubeBlocks.Count +" blocks");
 }