コード例 #1
0
        private void create_tree(TreeNode savegame, MyObjectBuilder_Sector mySector)
        {
            savegame.Nodes.Clear();
            TreeNode ships     = new TreeNode("Ships / Stations");
            TreeNode VoxelMaps = new TreeNode("Asteroids / Moons");
            TreeNode node      = null;

            foreach (Sandbox.Common.ObjectBuilders.MyObjectBuilder_EntityBase eb in mySector.SectorObjects)
            {
                switch (eb.TypeId)
                {
                case MyObjectBuilderTypeEnum.VoxelMap:
                    MyObjectBuilder_VoxelMap myMap = (MyObjectBuilder_VoxelMap)eb;
                    node     = new TreeNode("Asteroid");
                    node.Tag = myMap;
                    node.Nodes.Add(new TreeNode(myMap.EntityId.ToString()));
                    node.Nodes.Add(new TreeNode(myMap.PositionAndOrientation.ToString()));
                    node.Nodes.Add(new TreeNode(myMap.Filename.ToString()));
                    VoxelMaps.Nodes.Add(node);
                    break;

                case MyObjectBuilderTypeEnum.CubeGrid:
                    ships.Nodes.Add(this.newCubeGridNode((MyObjectBuilder_CubeGrid)eb));
                    break;
                }
            }
            savegame.Nodes.Add(ships);
            savegame.Nodes.Add(VoxelMaps);
            savegame.Tag = mySector;
        }
コード例 #2
0
        //load sector
        private void loadToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            string file = Path.Combine(this.saves_path, SectorTree.SelectedNode.Text, "SANDBOX_0_0_0_.sbs");

            if (File.Exists(file))
            {
                Sandbox.Common.ObjectBuilders.MyObjectBuilder_Base sec = Sandbox.Common.ObjectBuilders.MyObjectBuilder_Base.CreateNewObject(Sandbox.Common.ObjectBuilders.MyObjectBuilderTypeEnum.Sector);
                MyObjectBuilder_Sector mySector = (Sandbox.Common.ObjectBuilders.MyObjectBuilder_Sector)sec;
                Console.WriteLine(mySector.Position.ToString());
                try
                {
                    using (FileStream sr = File.Open(file, FileMode.Open))
                    {
                        if (Sandbox.Common.ObjectBuilders.MyObjectBuilder_Base.DeserializeXML(sr, out mySector))
                        {
                            this.create_tree(SectorTree.SelectedNode, mySector);
                        }
                    }
                }
                catch (System.NullReferenceException)
                {
                    MessageBox.Show("Unable to load that savegame, please report this!");
                }
            }
        }
コード例 #3
0
        private void CheckInventoryBagEntity(MyObjectBuilder_Sector sector)
        {
            List <int> removeList = new List <int>();

            for (int i = 0; i < sector.SectorObjects.Count; ++i)
            {
                var entityOb = sector.SectorObjects[i];

                if ((entityOb is MyObjectBuilder_ReplicableEntity) || (entityOb is MyObjectBuilder_InventoryBagEntity))
                {
                    var newBuilder = ConvertInventoryBagToEntityBase(entityOb);
                    Debug.Assert(newBuilder != null);
                    if (newBuilder != null)
                    {
                        sector.SectorObjects[i] = newBuilder;
                    }
                    else
                    {
                        removeList.Add(i);
                    }
                }
            }

            for (int i = removeList.Count - 1; i >= 0; --i)
            {
                sector.SectorObjects.RemoveAtFast(removeList[i]);
            }
        }
コード例 #4
0
        private void removePilotToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode node = SectorTree.SelectedNode;
            MyObjectBuilder_Sector sector = (MyObjectBuilder_Sector)node.Parent.Parent.Tag;

            Console.WriteLine("in method");

            if (node.Nodes.ContainsKey("Pilot"))
            {
                Console.WriteLine("Contains Pilot");
                TreeNode pilotNode = node.Nodes[node.Nodes.IndexOfKey("Pilot")];
                MyObjectBuilder_Cockpit cockpit = (MyObjectBuilder_Cockpit)pilotNode.Tag;
                long Pilot_id = 0;
                if (cockpit.Pilot != null)
                {
                    DialogResult dialogResult = MessageBox.Show("Overwrite \"" + SectorTree.SelectedNode.Parent.Parent.Text + "\"?", "Save", MessageBoxButtons.YesNo);
                    if (dialogResult == DialogResult.Yes)
                    {
                        MyObjectBuilder_Character pilot    = (MyObjectBuilder_Character)cockpit.Pilot;
                        MyObjectBuilder_Character newPilot = (MyObjectBuilder_Character)pilot.Clone();
                        MyPositionAndOrientation  newpos   = (MyPositionAndOrientation)newPilot.PositionAndOrientation;
                        newpos.Position.X = 0;
                        newpos.Position.Y = 0;
                        newpos.Position.Z = 0;
                        newPilot.PositionAndOrientation  = newpos;
                        newPilot.AutoenableJetpackDelay  = 0;
                        newPilot.JetpackEnabled          = true;
                        newPilot.Battery.ProducerEnabled = true;
                        cockpit.Pilot = null;
                        sector.SectorObjects.Add(newPilot);
                        Pilot_id = newPilot.EntityId;
                        string file       = Path.Combine(this.saves_path, SectorTree.SelectedNode.Parent.Parent.Text, "SANDBOX_0_0_0_.sbs");
                        string backupfile = Path.Combine(this.saves_path, SectorTree.SelectedNode.Parent.Parent.Text, "SANDBOX_0_0_0_.BAK2");
                        if (File.Exists(backupfile))
                        {
                            File.Delete(backupfile);
                        }
                        File.Move(file, backupfile);
                        label1.Text = "Saving...";
                        MyObjectBuilder_Sector mySector = (MyObjectBuilder_Sector)SectorTree.SelectedNode.Parent.Parent.Tag;
                        using (FileStream sr = File.Open(file, FileMode.Create))
                        {
                            MyObjectBuilder_Base.SerializeXML(sr, mySector);
                            sr.Dispose();
                        }
                        //now update the sbc file
                        String    sbcfile = Path.Combine(this.saves_path, node.Parent.Parent.Text, "Sandbox.sbc");
                        XDocument sbcFile = XDocument.Load(sbcfile);
                        sbcFile.Root.SetElementValue("ControlledObject", Pilot_id);
                        sbcFile.Save(sbcfile);
                        this.create_tree(node.Parent.Parent, mySector);
                        label1.Text = "";
                    }
                    else
                    {
                        return;
                    }
                }
            }
        }
コード例 #5
0
        private void PrepareBaseSession(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            ScriptManager.Init(checkpoint.ScriptManagerData);
            MyDefinitionManager.Static.LoadData(checkpoint.Mods);

            LoadGameDefinition(checkpoint);

            MyDefinitionManager.Static.TryGetDefinition <MyScenarioDefinition>(checkpoint.Scenario, out Scenario);

            WorldBoundaries = checkpoint.WorldBoundaries;

            FixIncorrectSettings(Settings);

            // Use whatever setting is in scenario if there was nothing in the file (0 min and max).
            // SE scenarios have nothing while ME scenarios have size defined.
            if (!WorldBoundaries.HasValue && Scenario != null)
            {
                WorldBoundaries = Scenario.WorldBoundaries;
            }

            MySector.InitEnvironmentSettings(sector.Environment);

            LoadDataComponents();
            LoadObjectBuildersComponents(checkpoint.SessionComponents);
        }
コード例 #6
0
        public static bool SaveSector(MyObjectBuilder_Sector sector, string sessionPath, Vector3I sectorPosition, out ulong sizeInBytes)
        {
            string sectorPath = GetSectorPath(sessionPath, sectorPosition);
            bool   flag       = MyObjectBuilderSerializer.SerializeXML(sectorPath, MySandboxGame.Config.CompressSaveGames, sector, out sizeInBytes, null);

            MyObjectBuilderSerializer.SerializePB(sectorPath + MyObjectBuilderSerializer.ProtobufferExtension, MySandboxGame.Config.CompressSaveGames, sector, out sizeInBytes);
            return(flag);
        }
コード例 #7
0
        public void Load(FileInfo fileInfo)
        {
            //Save the file info to the property
            FileInfo = fileInfo;

            //Read in the sector data
            MyObjectBuilder_Sector data = ReadSpaceEngineersFile <MyObjectBuilder_Sector, MyObjectBuilder_SectorSerializer>(this.FileInfo.FullName);

            //And instantiate the sector with the data
            m_Sector = new SectorEntity(data);
        }
コード例 #8
0
		public override void FixSessionObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
		{
            base.FixSessionObjectBuilders(checkpoint, sector);

			if (sector.AppVersion == 0)
			{
				HashSet<String> previouslyColored = new HashSet<String>();
				previouslyColored.Add("LargeBlockArmorBlock");
				previouslyColored.Add("LargeBlockArmorSlope");
				previouslyColored.Add("LargeBlockArmorCorner");
				previouslyColored.Add("LargeBlockArmorCornerInv");
				previouslyColored.Add("LargeRoundArmor_Slope");
				previouslyColored.Add("LargeRoundArmor_Corner");
				previouslyColored.Add("LargeRoundArmor_CornerInv");
				previouslyColored.Add("LargeHeavyBlockArmorBlock");
				previouslyColored.Add("LargeHeavyBlockArmorSlope");
				previouslyColored.Add("LargeHeavyBlockArmorCorner");
				previouslyColored.Add("LargeHeavyBlockArmorCornerInv");
				previouslyColored.Add("SmallBlockArmorBlock");
				previouslyColored.Add("SmallBlockArmorSlope");
				previouslyColored.Add("SmallBlockArmorCorner");
				previouslyColored.Add("SmallBlockArmorCornerInv");
				previouslyColored.Add("SmallHeavyBlockArmorBlock");
				previouslyColored.Add("SmallHeavyBlockArmorSlope");
				previouslyColored.Add("SmallHeavyBlockArmorCorner");
				previouslyColored.Add("SmallHeavyBlockArmorCornerInv");
				previouslyColored.Add("LargeBlockInteriorWall");

				foreach (var obj in sector.SectorObjects)
				{
					var grid = obj as MyObjectBuilder_CubeGrid;
					if (grid == null)
						continue;

					foreach (var block in grid.CubeBlocks)
					{
						if (block.TypeId != typeof(MyObjectBuilder_CubeBlock) || !previouslyColored.Contains(block.SubtypeName))
						{
							block.ColorMaskHSV = MyRenderComponentBase.OldGrayToHSV;
						}
					}
				}
			}

			if (sector.AppVersion <= 01100001)
			{
				CheckOxygenContainers(sector);
			}

            // TODO: this is disabled now because replication of MyEntity with components is not resolved, when you enable it make sure that corresponding 
            // definitions are also changed (InventoryBagDefinition/.... to EntityBase/...)
            //CheckInventoryBagEntity(sector);
		}
コード例 #9
0
 public static bool HasPlanets(this MyObjectBuilder_Sector sector)
 {
     if (sector.SectorObjects != null)
     {
         foreach (var ob in sector.SectorObjects)
         {
             if (ob is MyObjectBuilder_Planet)
             {
                 return(true);
             }
         }
     }
     return(false);
 }
コード例 #10
0
        private static MyObjectBuilder_Sector LoadSector(string path, bool allowXml, out ulong sizeInBytes, out bool needsXml)
        {
            MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_Sector>();
            sizeInBytes = 0L;
            needsXml    = false;
            MyObjectBuilder_Sector objectBuilder = null;
            string str = path + MyObjectBuilderSerializer.ProtobufferExtension;

            if (!MyFileSystem.FileExists(str))
            {
                if (!allowXml)
                {
                    needsXml = true;
                }
                else
                {
                    MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Sector>(path, out objectBuilder, out sizeInBytes);
                    if (!MyFileSystem.FileExists(str))
                    {
                        MyObjectBuilderSerializer.SerializePB(path + MyObjectBuilderSerializer.ProtobufferExtension, false, objectBuilder);
                    }
                }
            }
            else
            {
                MyObjectBuilderSerializer.DeserializePB <MyObjectBuilder_Sector>(str, out objectBuilder, out sizeInBytes);
                if ((objectBuilder == null) || (objectBuilder.SectorObjects == null))
                {
                    if (!allowXml)
                    {
                        needsXml = true;
                    }
                    else
                    {
                        MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Sector>(path, out objectBuilder, out sizeInBytes);
                        if (objectBuilder != null)
                        {
                            MyObjectBuilderSerializer.SerializePB(str, false, objectBuilder);
                        }
                    }
                }
            }
            if (objectBuilder != null)
            {
                return(objectBuilder);
            }
            MySandboxGame.Log.WriteLine("Incorrect save data");
            return(null);
        }
コード例 #11
0
        private static MyObjectBuilder_Sector LoadSector(string path, out ulong sizeInBytes)
        {
            MyObjectBuilder_Sector newSector = Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.CreateNewObject <MyObjectBuilder_Sector>();

            MyObjectBuilder_Sector result;

            Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Sector>(path, out result, out sizeInBytes);

            if (result == null)
            {
                MySandboxGame.Log.WriteLine("Incorrect save data");
                return(null);
            }
            return(result);
        }
コード例 #12
0
        public SectorEntity(MyObjectBuilder_Sector definition)
            : base(definition)
        {
            m_eventManager          = new BaseObjectManager();
            m_cubeGridManager       = new BaseObjectManager();
            m_voxelMapManager       = new BaseObjectManager();
            m_floatingObjectManager = new BaseObjectManager();
            m_meteorManager         = new BaseObjectManager();

            List <Event> events = new List <Event>();

            foreach (var sectorEvent in definition.SectorEvents.Events)
            {
                events.Add(new Event(sectorEvent));
            }

            List <CubeGridEntity> cubeGrids       = new List <CubeGridEntity>();
            List <VoxelMap>       voxelMaps       = new List <VoxelMap>();
            List <FloatingObject> floatingObjects = new List <FloatingObject>();
            List <Meteor>         meteors         = new List <Meteor>();

            foreach (var sectorObject in definition.SectorObjects)
            {
                if (sectorObject.TypeId == typeof(MyObjectBuilder_CubeGrid))
                {
                    cubeGrids.Add(new CubeGridEntity((MyObjectBuilder_CubeGrid)sectorObject));
                }
                else if (sectorObject.TypeId == typeof(MyObjectBuilder_VoxelMap))
                {
                    voxelMaps.Add(new VoxelMap((MyObjectBuilder_VoxelMap)sectorObject));
                }
                else if (sectorObject.TypeId == typeof(MyObjectBuilder_FloatingObject))
                {
                    floatingObjects.Add(new FloatingObject((MyObjectBuilder_FloatingObject)sectorObject));
                }
                else if (sectorObject.TypeId == typeof(MyObjectBuilder_Meteor))
                {
                    meteors.Add(new Meteor((MyObjectBuilder_Meteor)sectorObject));
                }
            }

            //Build the managers from the lists
            m_eventManager.Load(events);
            m_cubeGridManager.Load(cubeGrids);
            m_voxelMapManager.Load(voxelMaps);
            m_floatingObjectManager.Load(floatingObjects);
            m_meteorManager.Load(meteors);
        }
コード例 #13
0
        public SectorEntity( MyObjectBuilder_Sector definition )
            : base(definition)
        {
            m_eventManager = new BaseObjectManager( );
            m_cubeGridManager = new BaseObjectManager( );
            m_voxelMapManager = new BaseObjectManager( );
            m_floatingObjectManager = new BaseObjectManager( );
            m_meteorManager = new BaseObjectManager( );

            List<Event> events = new List<Event>( );
            foreach ( MyObjectBuilder_GlobalEventBase sectorEvent in definition.SectorEvents.Events )
            {
                events.Add( new Event( sectorEvent ) );
            }

            List<CubeGridEntity> cubeGrids = new List<CubeGridEntity>( );
            //List<VoxelMap> voxelMaps = new List<VoxelMap>( );
            List<FloatingObject> floatingObjects = new List<FloatingObject>( );
            List<Meteor> meteors = new List<Meteor>( );
            foreach ( MyObjectBuilder_EntityBase sectorObject in definition.SectorObjects )
            {
                if ( sectorObject.TypeId == typeof( MyObjectBuilder_CubeGrid ) )
                {
                    cubeGrids.Add( new CubeGridEntity( (MyObjectBuilder_CubeGrid)sectorObject ) );
                }
                //else if ( sectorObject.TypeId == typeof( MyObjectBuilder_VoxelMap ) )
                //{
                    //voxelMaps.Add( new VoxelMap( (MyObjectBuilder_VoxelMap)sectorObject ) );
                //}
                else if ( sectorObject.TypeId == typeof( MyObjectBuilder_FloatingObject ) )
                {
                    floatingObjects.Add( new FloatingObject( (MyObjectBuilder_FloatingObject)sectorObject ) );
                }
                else if ( sectorObject.TypeId == typeof( MyObjectBuilder_Meteor ) )
                {
                    meteors.Add( new Meteor( (MyObjectBuilder_Meteor)sectorObject ) );
                }
            }

            //Build the managers from the lists
            m_eventManager.Load( events );
            m_cubeGridManager.Load( cubeGrids );
            //m_voxelMapManager.Load( voxelMaps );
            m_floatingObjectManager.Load( floatingObjects );
            m_meteorManager.Load( meteors );
        }
コード例 #14
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TreeNode             node   = SectorTree.SelectedNode;
            MyObjectBuilder_Base myBase = (MyObjectBuilder_Base)node.Tag;

            if (myBase.TypeId == MyObjectBuilderTypeEnum.CubeGrid)
            {
                MyObjectBuilder_CubeGrid myGrid = (MyObjectBuilder_CubeGrid)myBase;
                TreeNode SectorNode             = node.Parent.Parent;
                MyObjectBuilder_Sector mySector = (MyObjectBuilder_Sector)SectorNode.Tag;
                Console.WriteLine(mySector.SectorObjects.Count());
                mySector.SectorObjects.Remove(myGrid);
                mySector.SectorObjects.TrimExcess();
                Console.WriteLine(mySector.SectorObjects.Count());
                node.Remove();
            }
        }
コード例 #15
0
        /// <summary>
        /// Gets entities to pack into the session snapshot, customized for a given user
        /// </summary>
        /// <param name="steamId"></param>
        /// <returns></returns>
        private static MyObjectBuilder_Sector GetClientSector(ulong steamId)
        {
            MyObjectBuilder_Sector ob = MySession.Static.GetSector(false);

            if (EssentialsPlugin.Instance.Config.PackRespawn)
            {
                ob.SectorObjects = new List <MyObjectBuilder_EntityBase>();
                var grids = new HashSet <MyCubeGrid>();

                /*
                 * foreach (IMyMedicalRoomProvider room in MyMedicalRoomsSystem.GetMedicalRoomsInScene())
                 * {
                 *  if (room.Closed || !room.IsWorking || !(room.SetFactionToSpawnee || room.HasPlayerAccess(MySession.Static.Players.TryGetIdentityId(steamId))))
                 *      continue;
                 *
                 *  grids.Add(((MyMedicalRoom)room).CubeGrid);
                 * }
                 */
                foreach (var respawn in MyRespawnComponent.GetAllRespawns())
                {
                    if (respawn.Entity.Closed || !respawn.Entity.IsWorking || !respawn.CanPlayerSpawn(MySession.Static.Players.TryGetIdentityId(steamId), true))
                    {
                        continue;
                    }

                    grids.Add(respawn.Entity.CubeGrid);
                }

                if (EssentialsPlugin.Instance.Config.MaxPackedRespawnSize > 0)
                {
                    foreach (MyCubeGrid spawngrid in grids)
                    {
                        if (spawngrid.BlocksCount > EssentialsPlugin.Instance.Config.MaxPackedRespawnSize)
                        {
                            continue;
                        }

                        ob.SectorObjects.Add(spawngrid.GetObjectBuilder());
                    }
                }
            }

            return(ob);
        }
コード例 #16
0
        private void importShipToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            DialogResult result = fileopen.ShowDialog();

            if (result == DialogResult.OK)
            {
                string filename = fileopen.FileName;
                MyObjectBuilder_CubeGrid MyCubeGrid = (MyObjectBuilder_CubeGrid)MyObjectBuilder_Base.CreateNewObject(MyObjectBuilderTypeEnum.CubeGrid);
                using (FileStream sr = File.Open(filename, FileMode.Open))
                {
                    if (Sandbox.Common.ObjectBuilders.MyObjectBuilder_Base.DeserializeXML(sr, out MyCubeGrid))
                    {
                        TreeNode savegame_node          = SectorTree.SelectedNode;
                        MyObjectBuilder_Sector mySector = (MyObjectBuilder_Sector)savegame_node.Tag;
                        mySector.SectorObjects.Add(MyCubeGrid);
                        this.create_tree(savegame_node, mySector);
                    }
                }
            }
        }
コード例 #17
0
        private void CheckOxygenContainers(MyObjectBuilder_Sector sector)
        {
            foreach (var objectBuilder in sector.SectorObjects)
            {
                var gridBuilder = objectBuilder as MyObjectBuilder_CubeGrid;
                if (gridBuilder != null)
                {
                    foreach (var cubeBuilder in gridBuilder.CubeBlocks)
                    {
                        var oxygenTankBuilder = cubeBuilder as MyObjectBuilder_OxygenTank;
                        if (oxygenTankBuilder != null)
                        {
                            CheckOxygenInventory(oxygenTankBuilder.Inventory);
                            continue;
                        }

                        var oxygenGeneratorBuilder = cubeBuilder as MyObjectBuilder_OxygenGenerator;
                        if (oxygenGeneratorBuilder != null)
                        {
                            CheckOxygenInventory(oxygenGeneratorBuilder.Inventory);
                            continue;
                        }
                    }
                }

                var floatingObjectBuilder = objectBuilder as MyObjectBuilder_FloatingObject;
                if (floatingObjectBuilder != null)
                {
                    var oxygenContainer = floatingObjectBuilder.Item.PhysicalContent as MyObjectBuilder_OxygenContainerObject;
                    if (oxygenContainer == null)
                    {
                        continue;
                    }

                    FixOxygenContainer(oxygenContainer);
                }
            }
        }
コード例 #18
0
        private void PrepareBaseSession(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            ScriptManager.Init(checkpoint.ScriptManagerData);
            MyDefinitionManager.Static.LoadData(checkpoint.Mods);

            LoadGameDefinition(checkpoint);

            var fonts = MyDefinitionManager.Static.GetFontDefinitions();

            foreach (var font in fonts)
            {
                if (!MyGuiManager.FontExists(font.Id.SubtypeId.String))
                {
                    VRageRender.MyRenderProxy.CreateFont((int)font.Id.SubtypeId, font.Path, false);
                }
            }


            MyDefinitionManager.Static.TryGetDefinition <MyScenarioDefinition>(checkpoint.Scenario, out Scenario);

            WorldBoundaries = checkpoint.WorldBoundaries;

            FixIncorrectSettings(Settings);

            // Use whatever setting is in scenario if there was nothing in the file (0 min and max).
            // SE scenarios have nothing while ME scenarios have size defined.
            if (!WorldBoundaries.HasValue && Scenario != null)
            {
                WorldBoundaries = Scenario.WorldBoundaries;
            }

            MySector.InitEnvironmentSettings(sector.Environment);

            LoadDataComponents();
            LoadObjectBuildersComponents(checkpoint.SessionComponents);
        }
コード例 #19
0
		private void CheckOxygenContainers(MyObjectBuilder_Sector sector)
		{
			foreach (var objectBuilder in sector.SectorObjects)
			{
				var gridBuilder = objectBuilder as MyObjectBuilder_CubeGrid;
				if (gridBuilder != null)
				{
					foreach (var cubeBuilder in gridBuilder.CubeBlocks)
					{
						var oxygenTankBuilder = cubeBuilder as MyObjectBuilder_OxygenTank;
						if (oxygenTankBuilder != null)
						{
							CheckOxygenInventory(oxygenTankBuilder.Inventory);
							continue;
						}

						var oxygenGeneratorBuilder = cubeBuilder as MyObjectBuilder_OxygenGenerator;
						if (oxygenGeneratorBuilder != null)
						{
							CheckOxygenInventory(oxygenGeneratorBuilder.Inventory);
							continue;
						}
					}
				}

				var floatingObjectBuilder = objectBuilder as MyObjectBuilder_FloatingObject;
				if (floatingObjectBuilder != null)
				{
					var oxygenContainer = floatingObjectBuilder.Item.PhysicalContent as MyObjectBuilder_OxygenContainerObject;
					if (oxygenContainer == null)
						continue;
					
					FixOxygenContainer(oxygenContainer);
				}
			}
		}
コード例 #20
0
        //save sector
        private void saveToolStripMenuItem_Click_1(object sender, EventArgs e)
        {
            DialogResult dialogResult = MessageBox.Show("Overwrite \"" + SectorTree.SelectedNode.Text + "\"?", "Save", MessageBoxButtons.YesNo);

            if (dialogResult == DialogResult.Yes)
            {
                string file       = Path.Combine(this.saves_path, SectorTree.SelectedNode.Text, "SANDBOX_0_0_0_.sbs");
                string backupfile = Path.Combine(this.saves_path, SectorTree.SelectedNode.Text, "SANDBOX_0_0_0_.BAK2");
                if (File.Exists(backupfile))
                {
                    File.Delete(backupfile);
                }
                File.Move(file, backupfile);
                label1.Text = "Saving...";
                MyObjectBuilder_Sector mySector = (MyObjectBuilder_Sector)SectorTree.SelectedNode.Tag;
                using (FileStream sr = File.Open(file, FileMode.Create))
                {
                    MyObjectBuilder_Base.SerializeXML(sr, mySector);
                    sr.Dispose();
                }

                label1.Text = "";
            }
        }
コード例 #21
0
        static MyWorldGenerator()
        {
            if (MyFakes.TEST_PREFABS_FOR_INCONSISTENCIES)
            {
                string prefabDir   = Path.Combine(MyFileSystem.ContentPath, "Data", "Prefabs");
                var    prefabFiles = Directory.GetFiles(prefabDir);
                foreach (var prefabFile in prefabFiles)
                {
                    if (Path.GetExtension(prefabFile) != ".sbc")
                    {
                        continue;
                    }

                    MyObjectBuilder_CubeGrid result = null;
                    var fsPath = Path.Combine(MyFileSystem.ContentPath, prefabFile);
                    MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_CubeGrid>(fsPath, out result);

                    if (result == null)
                    {
                        continue;
                    }

                    foreach (var block in result.CubeBlocks)
                    {
                        if (block.IntegrityPercent == 0.0f)
                        {
                            Debug.Assert(false, "Inconsistent block in prefab file " + prefabFile);
                            break;
                        }
                    }
                }

                string worldDir  = Path.Combine(MyFileSystem.ContentPath, "Worlds");
                var    worldDirs = Directory.GetDirectories(worldDir);
                foreach (var dir in worldDirs)
                {
                    var files = Directory.GetFiles(dir);
                    foreach (var file in files)
                    {
                        if (Path.GetExtension(file) != ".sbs")
                        {
                            continue;
                        }

                        MyObjectBuilder_Sector result = null;

                        var fsPath = Path.Combine(MyFileSystem.ContentPath, file);
                        MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Sector>(fsPath, out result);

                        Debug.Assert(result != null, "Unloadable world: " + file);
                        foreach (var obj in result.SectorObjects)
                        {
                            if (obj.TypeId == typeof(MyObjectBuilder_CubeGrid))
                            {
                                var grid = (MyObjectBuilder_CubeGrid)obj;
                                foreach (var block in grid.CubeBlocks)
                                {
                                    if (block.IntegrityPercent == 0.0f)
                                    {
                                        Debug.Assert(false, "Inconsistent block in save " + file);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #22
0
 public virtual void FixSessionObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
 { }
コード例 #23
0
        public static bool SaveSector(MyObjectBuilder_Sector sector, string sessionPath, Vector3I sectorPosition, out ulong sizeInBytes)
        {
            var relativePath = GetSectorPath(sessionPath, sectorPosition);

            return(Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.SerializeXML(relativePath, MySandboxGame.Config.CompressSaveGames, sector, out sizeInBytes));
        }
コード例 #24
0
 public virtual void FixSessionComponentObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
 {
     if (checkpoint.ScriptManagerData == null)
         checkpoint.ScriptManagerData = (MyObjectBuilder_ScriptManager)checkpoint.SessionComponents.FirstOrDefault(x => x is MyObjectBuilder_ScriptManager);
 }
コード例 #25
0
 public virtual void FixSessionObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
 {
 }
コード例 #26
0
 public static bool SaveSector(MyObjectBuilder_Sector sector, string sessionPath, Vector3I sectorPosition, out ulong sizeInBytes)
 {
     var relativePath = GetSectorPath(sessionPath, sectorPosition);
     return MyObjectBuilderSerializer.SerializeXML(relativePath, MySandboxGame.Config.CompressSaveGames, sector, out sizeInBytes);
 }
コード例 #27
0
ファイル: MySession.cs プロジェクト: liiir1985/SpaceEngineers
        private void LoadWorld(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            // Run compatibility helper.
            MySandboxGame.Static.SessionCompatHelper.FixSessionObjectBuilders(checkpoint, sector);

            //MyAudio.Static.Mute = true
            MyEntities.MemoryLimitAddFailureReset();

            ElapsedGameTime = new TimeSpan(checkpoint.ElapsedGameTime);
            InGameTime = checkpoint.InGameTime;
            Name = checkpoint.SessionName;
            Description = checkpoint.Description;
            PromotedUsers = new HashSet<ulong>(checkpoint.PromotedUsers ?? Enumerable.Empty<ulong>());
            Briefing = checkpoint.Briefing;
            BriefingVideo = checkpoint.BriefingVideo;
            WorkshopId = checkpoint.WorkshopId;
            Password = checkpoint.Password;
            PreviousEnvironmentHostility = checkpoint.PreviousEnvironmentHostility;
            RequiresDX = checkpoint.RequiresDX;
            FixIncorrectSettings(Settings);

            AppVersionFromSave = checkpoint.AppVersion;

            if (MyFakes.ENABLE_BATTLE_SYSTEM)
            {
                VoxelHandVolumeChanged = sector.VoxelHandVolumeChanged;
            }

            MyToolbarComponent.InitCharacterToolbar(checkpoint.CharacterToolbar);

            LoadCameraControllerSettings(checkpoint);;

            Sync.Players.RespawnComponent.InitFromCheckpoint(checkpoint);

            MyPlayer.PlayerId savingPlayer = new MyPlayer.PlayerId();
            MyPlayer.PlayerId? savingPlayerNullable = null;
            bool reuseSavingPlayerIdentity = TryFindSavingPlayerId(checkpoint.ControlledEntities, checkpoint.ControlledObject, out savingPlayer);
            if (reuseSavingPlayerIdentity && !(IsScenario && Static.OnlineMode != MyOnlineModeEnum.OFFLINE))
                savingPlayerNullable = savingPlayer;

            // Identities have to be loaded before entities (because of ownership)
            if (Sync.IsServer || (!Battle && MyPerGameSettings.Game == GameEnum.ME_GAME) || (!IsScenario && MyPerGameSettings.Game == GameEnum.SE_GAME)
                || (!IsScenario && MyPerGameSettings.Game == GameEnum.VRS_GAME))
                Sync.Players.LoadIdentities(checkpoint, savingPlayerNullable);

            Toolbars.LoadToolbars(checkpoint);

            if (!MyEntities.Load(sector.SectorObjects))
            {
                ShowLoadingError();
            }
            MySandboxGame.Static.SessionCompatHelper.AfterEntitiesLoad(sector.AppVersion);

            if (checkpoint.Factions != null && (Sync.IsServer || (!Battle && MyPerGameSettings.Game == GameEnum.ME_GAME) || (!IsScenario && MyPerGameSettings.Game == GameEnum.SE_GAME)))
            {
                Static.Factions.Init(checkpoint.Factions);
            }

            MyGlobalEvents.LoadEvents(sector.SectorEvents);
            // Regenerate default events if they are empty (i.e. we are loading an old save)

            // Initialize Spectator light
            MySpectatorCameraController.Static.InitLight(checkpoint.SpectatorIsLightOn);

            // MySpectator.Static.SpectatorCameraMovement = checkpoint.SpectatorCameraMovement;
            MySpectatorCameraController.Static.SetViewMatrix(MatrixD.Invert(checkpoint.SpectatorPosition.GetMatrix()));

            if (MyPerGameSettings.Game == GameEnum.UNKNOWN_GAME || ((!Battle && MyPerGameSettings.Game == GameEnum.ME_GAME) || ((!IsScenario || Static.OnlineMode == MyOnlineModeEnum.OFFLINE) && MyPerGameSettings.Game == GameEnum.SE_GAME)
                || ((!IsScenario || Static.OnlineMode == MyOnlineModeEnum.OFFLINE) && MyPerGameSettings.Game == GameEnum.VRS_GAME)))
            {
                if (!(Static.IsScenario && Static.Settings.StartInRespawnScreen))
                {
                    Sync.Players.LoadConnectedPlayers(checkpoint, savingPlayerNullable);
                    Sync.Players.LoadControlledEntities(checkpoint.ControlledEntities, checkpoint.ControlledObject, savingPlayerNullable);
                }
            }
            LoadCamera(checkpoint);

            //fix: saved in survival with dead player, changed to creative, loaded game, no character with no way to respawn
            if (CreativeMode && !Engine.Platform.Game.IsDedicated && LocalHumanPlayer != null && LocalHumanPlayer.Character != null && LocalHumanPlayer.Character.IsDead)
                MyPlayerCollection.RequestLocalRespawn();

            if (MyMultiplayer.Static != null && !Sync.IsServer)
            {
                Sync.Layer.TransportLayer.SendMessage(MyMessageId.CLIENT_READY, null, true, new EndpointId(Sync.ServerId));
                ((MyReplicationClient)MyMultiplayer.Static.ReplicationLayer).OnLocalClientReady();
            }

            // Create the player if he/she does not exist (on clients and server)
            if (!Engine.Platform.Game.IsDedicated && LocalHumanPlayer == null)
            {
                Sync.Players.RequestNewPlayer(0, MySteam.UserName, null);
            }
            // Fix missing controlled entity. This should be needed only on the server.
            // On the client, it will be done in reaction to new player creation (see "Create the player" above)
            else if (ControlledEntity == null && Sync.IsServer && !Engine.Platform.Game.IsDedicated)
            {
                MyLog.Default.WriteLine("ControlledObject was null, respawning character");
                m_cameraAwaitingEntity = true;
                MyPlayerCollection.RequestLocalRespawn();
            }

            if (!Engine.Platform.Game.IsDedicated)
            {
                var playerId = new MyPlayer.PlayerId(Sync.MyId, 0);
                var toolbar = Toolbars.TryGetPlayerToolbar(playerId);
                if (toolbar == null)
                {
                    MyToolBarCollection.RequestCreateToolbar(playerId);
                    MyToolbarComponent.InitCharacterToolbar(Scenario.DefaultToolbar);
                }
                else
                {
                    MyToolbarComponent.InitCharacterToolbar(toolbar.GetObjectBuilder());
                }
            }

            Gpss.LoadGpss(checkpoint);

            LoadChatHistory(checkpoint);

            if (MyFakes.ENABLE_MISSION_TRIGGERS)
                MySessionComponentMissionTriggers.Static.Load(checkpoint.MissionTriggers);

            MyEncounterGenerator.Load(sector.Encounters);
            MyRenderProxy.RebuildCullingStructure();

            Settings.ResetOwnership = false;

            if (MyFinalBuildConstants.IS_OFFICIAL && !CreativeMode)
                MyDebugDrawSettings.DEBUG_DRAW_PHYSICS = false;

            MyRenderProxy.CollectGarbage();
        }
コード例 #28
0
        public virtual void FixSessionObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            if (sector.AppVersion == 0)
            {
                HashSet <String> previouslyColored = new HashSet <String>();
                previouslyColored.Add("LargeBlockArmorBlock");
                previouslyColored.Add("LargeBlockArmorSlope");
                previouslyColored.Add("LargeBlockArmorCorner");
                previouslyColored.Add("LargeBlockArmorCornerInv");
                previouslyColored.Add("LargeRoundArmor_Slope");
                previouslyColored.Add("LargeRoundArmor_Corner");
                previouslyColored.Add("LargeRoundArmor_CornerInv");
                previouslyColored.Add("LargeHeavyBlockArmorBlock");
                previouslyColored.Add("LargeHeavyBlockArmorSlope");
                previouslyColored.Add("LargeHeavyBlockArmorCorner");
                previouslyColored.Add("LargeHeavyBlockArmorCornerInv");
                previouslyColored.Add("SmallBlockArmorBlock");
                previouslyColored.Add("SmallBlockArmorSlope");
                previouslyColored.Add("SmallBlockArmorCorner");
                previouslyColored.Add("SmallBlockArmorCornerInv");
                previouslyColored.Add("SmallHeavyBlockArmorBlock");
                previouslyColored.Add("SmallHeavyBlockArmorSlope");
                previouslyColored.Add("SmallHeavyBlockArmorCorner");
                previouslyColored.Add("SmallHeavyBlockArmorCornerInv");
                previouslyColored.Add("LargeBlockInteriorWall");

                foreach (var obj in sector.SectorObjects)
                {
                    var grid = obj as MyObjectBuilder_CubeGrid;
                    if (grid == null)
                    {
                        continue;
                    }

                    foreach (var block in grid.CubeBlocks)
                    {
                        if (block.TypeId != typeof(MyObjectBuilder_CubeBlock) || !previouslyColored.Contains(block.SubtypeName))
                        {
                            block.ColorMaskHSV = MyRenderComponentBase.OldGrayToHSV;
                        }
                    }
                }
            }
        }
コード例 #29
0
        private void CheckInventoryBagEntity(MyObjectBuilder_Sector sector)
        {
            List<int> removeList = new List<int>();
            for (int i = 0; i < sector.SectorObjects.Count; ++i)
            {
                var entityOb = sector.SectorObjects[i];

                if ((entityOb is MyObjectBuilder_ReplicableEntity) || (entityOb is MyObjectBuilder_InventoryBagEntity))
                {
                    var newBuilder = ConvertInventoryBagToEntityBase(entityOb);
                    Debug.Assert(newBuilder != null);
                    if (newBuilder != null)
                        sector.SectorObjects[i] = newBuilder;
                    else
                        removeList.Add(i);
                }
            }

            for (int i = removeList.Count - 1; i >= 0; --i)
            {
                sector.SectorObjects.RemoveAtFast(removeList[i]);
            }
        }
コード例 #30
0
 public virtual void FixSessionComponentObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
 {
     if (checkpoint.ScriptManagerData == null)
     {
         checkpoint.ScriptManagerData = (MyObjectBuilder_ScriptManager)checkpoint.SessionComponents.FirstOrDefault(x => x is MyObjectBuilder_ScriptManager);
     }
 }
コード例 #31
0
        public override void FixSessionObjectBuilders(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            base.FixSessionObjectBuilders(checkpoint, sector);

            if (sector.AppVersion == 0)
            {
                HashSet <String> previouslyColored = new HashSet <String>();
                previouslyColored.Add("LargeBlockArmorBlock");
                previouslyColored.Add("LargeBlockArmorSlope");
                previouslyColored.Add("LargeBlockArmorCorner");
                previouslyColored.Add("LargeBlockArmorCornerInv");
                previouslyColored.Add("LargeRoundArmor_Slope");
                previouslyColored.Add("LargeRoundArmor_Corner");
                previouslyColored.Add("LargeRoundArmor_CornerInv");
                previouslyColored.Add("LargeHeavyBlockArmorBlock");
                previouslyColored.Add("LargeHeavyBlockArmorSlope");
                previouslyColored.Add("LargeHeavyBlockArmorCorner");
                previouslyColored.Add("LargeHeavyBlockArmorCornerInv");
                previouslyColored.Add("SmallBlockArmorBlock");
                previouslyColored.Add("SmallBlockArmorSlope");
                previouslyColored.Add("SmallBlockArmorCorner");
                previouslyColored.Add("SmallBlockArmorCornerInv");
                previouslyColored.Add("SmallHeavyBlockArmorBlock");
                previouslyColored.Add("SmallHeavyBlockArmorSlope");
                previouslyColored.Add("SmallHeavyBlockArmorCorner");
                previouslyColored.Add("SmallHeavyBlockArmorCornerInv");
                previouslyColored.Add("LargeBlockInteriorWall");

                foreach (var obj in sector.SectorObjects)
                {
                    var grid = obj as MyObjectBuilder_CubeGrid;
                    if (grid == null)
                    {
                        continue;
                    }

                    foreach (var block in grid.CubeBlocks)
                    {
                        if (block.TypeId != typeof(MyObjectBuilder_CubeBlock) || !previouslyColored.Contains(block.SubtypeName))
                        {
                            block.ColorMaskHSV = MyRenderComponentBase.OldGrayToHSV;
                        }
                    }
                }
            }

            if (sector.AppVersion <= 01100001)
            {
                CheckOxygenContainers(sector);
            }

            // TODO: this is disabled now because replication of MyEntity with components is not resolved, when you enable it make sure that corresponding
            // definitions are also changed (InventoryBagDefinition/.... to EntityBase/...)
            //CheckInventoryBagEntity(sector);
        }
コード例 #32
0
        private static void LoadWorld(MyObjectBuilder_Checkpoint checkpoint, MyObjectBuilder_Sector sector)
        {
            Dictionary <ulong, AdminSettingsEnum> AdminSettingsList = (Dictionary <ulong, AdminSettingsEnum>)RemoteAdminSettings.GetValue(MySession.Static);

            AdminSettingsList.Clear();

            MySession.Static.PromotedUsers.Clear();
            MySession.Static.CreativeTools.Clear();

            MyEntities.MemoryLimitAddFailureReset();
            MySession.Static.ElapsedGameTime = new TimeSpan(checkpoint.ElapsedGameTime);
            MySession.Static.InGameTime      = checkpoint.InGameTime;
            MySession.Static.Name            = MyStatControlText.SubstituteTexts(checkpoint.SessionName);
            MySession.Static.Description     = checkpoint.Description;


            if (checkpoint.PromotedUsers != null)
            {
                MySession.Static.PromotedUsers = checkpoint.PromotedUsers.Dictionary;
            }
            else
            {
                MySession.Static.PromotedUsers = new Dictionary <ulong, MyPromoteLevel>();
            }



            foreach (KeyValuePair <MyObjectBuilder_Checkpoint.PlayerId, MyObjectBuilder_Player> item in checkpoint.AllPlayersData.Dictionary)
            {
                ulong             clientId          = item.Key.GetClientId();
                AdminSettingsEnum adminSettingsEnum = (AdminSettingsEnum)item.Value.RemoteAdminSettings;
                if (checkpoint.RemoteAdminSettings != null && checkpoint.RemoteAdminSettings.Dictionary.TryGetValue(clientId, out var value))
                {
                    adminSettingsEnum = (AdminSettingsEnum)value;
                }
                if (!MyPlatformGameSettings.IsIgnorePcuAllowed)
                {
                    adminSettingsEnum &= ~AdminSettingsEnum.IgnorePcu;
                    adminSettingsEnum &= ~AdminSettingsEnum.KeepOriginalOwnershipOnPaste;
                }


                AdminSettingsList[clientId] = adminSettingsEnum;
                if (!Sync.IsDedicated && clientId == Sync.MyId)
                {
                    AdminSettings.SetValue(MySession.Static, adminSettingsEnum);

                    //m_adminSettings = adminSettingsEnum;
                }



                if (!MySession.Static.PromotedUsers.TryGetValue(clientId, out var value2))
                {
                    value2 = MyPromoteLevel.None;
                }
                if (item.Value.PromoteLevel > value2)
                {
                    MySession.Static.PromotedUsers[clientId] = item.Value.PromoteLevel;
                }
                if (!MySession.Static.CreativeTools.Contains(clientId) && item.Value.CreativeToolsEnabled)
                {
                    MySession.Static.CreativeTools.Add(clientId);
                }
            }


            //MySession.Static.WorkshopId = checkpoint.WorkshopId;
            MySession.Static.Password = checkpoint.Password;
            MySession.Static.PreviousEnvironmentHostility = checkpoint.PreviousEnvironmentHostility;
            MySession.Static.RequiresDX = checkpoint.RequiresDX;
            MySession.Static.CustomLoadingScreenImage = checkpoint.CustomLoadingScreenImage;
            MySession.Static.CustomLoadingScreenText  = checkpoint.CustomLoadingScreenText;
            MySession.Static.CustomSkybox             = checkpoint.CustomSkybox;
            //FixIncorrectSettings(Settings);
            // MySession.Static.AppVersionFromSave = checkpoint.AppVersion;
            //MyToolbarComponent.InitCharacterToolbar(checkpoint.CharacterToolbar);
            //LoadCameraControllerSettings(checkpoint);



            SeamlessClient.TryShow("LocalPlayerID: " + MySession.Static.LocalPlayerId);
            //checkpoint.Gps.Dictionary.TryGetValue(MySession.Static.LocalPlayerId, out MyObjectBuilder_Gps GPSCollection);
            //SeamlessClient.TryShow("You have " + GPSCollection.Entries.Count + " gps points!");



            MySession.Static.Gpss = new MyGpsCollection();
            MySession.Static.Gpss.LoadGpss(checkpoint);
            MyRenderProxy.RebuildCullingStructure();
            //MySession.Static.Toolbars.LoadToolbars(checkpoint);

            Sync.Players.RespawnComponent.InitFromCheckpoint(checkpoint);
        }
コード例 #33
0
        static MyWorldGenerator()
        {
            m_compatStaticAsteroids.Add("centralAsteroid", new Vector3(-467.79776, -344.905579, -422.073059));
            m_compatStaticAsteroids.Add("centralAsteroidmoon0", new Vector3(-76.98491, -131.79158, -24.2211456));
            m_compatStaticAsteroids.Add("centralAsteroidmoon1", new Vector3(-101.686935, -118.12616, -210.164291));
            m_compatStaticAsteroids.Add("centralAsteroidmoon2", new Vector3(-256.495361, 38.2605057, -183.8953));
            m_compatStaticAsteroids.Add("centralAsteroidmoon3", new Vector3(-56.29669, -140.993454, -76.5553));
            m_compatStaticAsteroids.Add("centralAsteroidmoon4", new Vector3(-246.923538, 87.1476, -112.943687));
            m_compatStaticAsteroids.Add("asteroid0", new Vector3(1510.89124, -465.1121, 260.685));
            m_compatStaticAsteroids.Add("asteroid0moon0", new Vector3(1662.6283, -162.567474, 359.632416));
            m_compatStaticAsteroids.Add("asteroid0moon1", new Vector3(1748.95581, -338.9174, 326.005432));
            m_compatStaticAsteroids.Add("asteroid0moon2", new Vector3(1746.39221, -287.431152, 595.522766));
            m_compatStaticAsteroids.Add("asteroid0moon3", new Vector3(1698.522, -135.195282, 511.5056));
            m_compatStaticAsteroids.Add("asteroid0moon4", new Vector3(1828.02527, -266.84, 370.210022));
            m_compatStaticAsteroids.Add("asteroid1", new Vector3(868.609863, -770.4491, -688.579956));
            m_compatStaticAsteroids.Add("asteroid1moon0", new Vector3(1155.94092, -630.9224, -408.786469));
            m_compatStaticAsteroids.Add("asteroid1moon1", new Vector3(1201.52026, -692.583, -447.062317));
            m_compatStaticAsteroids.Add("asteroid1moon2", new Vector3(1202.91467, -715.0832, -543.2147));
            m_compatStaticAsteroids.Add("asteroid1moon3", new Vector3(1124.04163, -583.4918, -554.5276));
            m_compatStaticAsteroids.Add("asteroid1moon4", new Vector3(1209.46143, -724.96875, -496.102417));
            m_compatStaticAsteroids.Add("asteroid2", new Vector3(-868.6959, -717.699, 709.567261));
            m_compatStaticAsteroids.Add("asteroid2moon0", new Vector3(-740.1664, -766.9268, 976.74));
            m_compatStaticAsteroids.Add("asteroid2moon1", new Vector3(-808.041138, -625.8883, 968.462769));
            m_compatStaticAsteroids.Add("asteroid2moon2", new Vector3(-602.8258, -688.6499, 1027.35132));
            m_compatStaticAsteroids.Add("asteroid2moon3", new Vector3(-629.0064, -643.9914, 759.6818));
            m_compatStaticAsteroids.Add("asteroid2moon4", new Vector3(-629.370056, -791.147339, 864.577942));
            m_compatStaticAsteroids.Add("asteroid3", new Vector3(29.2436523, -1853.01147, 158.969727));
            m_compatStaticAsteroids.Add("asteroid3moon0", new Vector3(215.777008, -1559.10168, 460.8993));
            m_compatStaticAsteroids.Add("asteroid3moon1", new Vector3(350.500336, -1600.10486, 305.328857));
            m_compatStaticAsteroids.Add("asteroid3moon2", new Vector3(88.53842, -1598.97961, 318.699341));
            m_compatStaticAsteroids.Add("asteroid3moon3", new Vector3(287.0002, -1793.83484, 327.860352));
            m_compatStaticAsteroids.Add("asteroid3moon4", new Vector3(334.049744, -1568.85254, 315.171417));
            m_compatStaticAsteroids.Add("asteroid4", new Vector3(-1011.94885, -688.988464, 1573.34753));
            m_compatStaticAsteroids.Add("asteroid4moon0", new Vector3(-948.649658, -471.660126, 1692.58374));
            m_compatStaticAsteroids.Add("asteroid4moon1", new Vector3(-952.0157, -456.203979, 1823.614));
            m_compatStaticAsteroids.Add("asteroid4moon2", new Vector3(-943.316467, -517.9845, 1848.04944));
            m_compatStaticAsteroids.Add("asteroid4moon3", new Vector3(-948.6832, -429.600525, 1802.581));
            m_compatStaticAsteroids.Add("asteroid4moon4", new Vector3(-700.344849, -416.96402, 1723.02759));
            m_compatStaticAsteroids.Add("asteroid5", new Vector3(-408.154449, 1190.29834, 527.698364));
            m_compatStaticAsteroids.Add("asteroid5moon0", new Vector3(-300.982117, 1336.61035, 627.345764));
            m_compatStaticAsteroids.Add("asteroid5moon1", new Vector3(-137.878265, 1134.39661, 675.0172));
            m_compatStaticAsteroids.Add("asteroid5moon2", new Vector3(-252.941559, 1259.60791, 865.0205));
            m_compatStaticAsteroids.Add("asteroid5moon3", new Vector3(-77.54451, 1307.79578, 699.0752));
            m_compatStaticAsteroids.Add("asteroid5moon4", new Vector3(-208.0395, 1260.0542, 869.368042));
            m_compatStaticAsteroids.Add("asteroid6", new Vector3(-619.9507, -1807.48132, 1206.3573));
            m_compatStaticAsteroids.Add("asteroid6moon0", new Vector3(-410.582458, -1490.075, 1317.91125));
            m_compatStaticAsteroids.Add("asteroid6moon1", new Vector3(-359.675537, -1510.88892, 1481.41711));
            m_compatStaticAsteroids.Add("asteroid6moon2", new Vector3(-550.6644, -1589.871, 1480.7312));
            m_compatStaticAsteroids.Add("asteroid6moon3", new Vector3(-567.8957, -1562.03906, 1406.0592));
            m_compatStaticAsteroids.Add("asteroid6moon4", new Vector3(-410.3158, -1758.13623, 1355.47876));
            m_compatStaticAsteroids.Add("asteroid7", new Vector3(-674.2594, -493.379578, -1447.60425));
            m_compatStaticAsteroids.Add("asteroid7moon0", new Vector3(-623.499268, -415.767761, -1304.246));
            m_compatStaticAsteroids.Add("asteroid7moon1", new Vector3(-554.9427, -385.733765, -1379.34668));
            m_compatStaticAsteroids.Add("asteroid7moon2", new Vector3(-568.8472, -307.443756, -1244.019));
            m_compatStaticAsteroids.Add("asteroid7moon3", new Vector3(-373.1848, -331.604126, -1223.31348));
            m_compatStaticAsteroids.Add("asteroid7moon4", new Vector3(-618.0778, -367.864777, -1239.19421));
            m_compatStaticAsteroids.Add("asteroid8", new Vector3(-477.607819, 366.410522, -803.1929));
            m_compatStaticAsteroids.Add("asteroid8moon0", new Vector3(-310.096741, 704.0997, -637.173));
            m_compatStaticAsteroids.Add("asteroid8moon1", new Vector3(-255.818344, 705.065735, -621.4319));
            m_compatStaticAsteroids.Add("asteroid8moon2", new Vector3(-238.096176, 564.4208, -469.0432));
            m_compatStaticAsteroids.Add("asteroid8moon3", new Vector3(-215.801025, 500.157227, -491.888367));
            m_compatStaticAsteroids.Add("asteroid8moon4", new Vector3(-246.462, 686.4795, -678.764648));
            m_compatStaticAsteroids.Add("asteroid9", new Vector3(-263.329651, 511.187561, -735.3834));
            m_compatStaticAsteroids.Add("asteroid9moon0", new Vector3(-210.570984, 588.0855, -597.6558));
            m_compatStaticAsteroids.Add("asteroid9moon1", new Vector3(41.102623, 502.5733, -611.104553));
            m_compatStaticAsteroids.Add("asteroid9moon2", new Vector3(71.4354858, 620.224854, -533.9093));
            m_compatStaticAsteroids.Add("asteroid9moon3", new Vector3(37.0611725, 650.394, -614.7657));
            m_compatStaticAsteroids.Add("asteroid9moon4", new Vector3(-10.148819, 690.253357, -617.6583));
            m_compatStaticAsteroids.Add("asteroid10", new Vector3(1220.54272, -396.55835, -1067.83179));
            m_compatStaticAsteroids.Add("asteroid10moon0", new Vector3(1283.41455, -141.081909, -833.4448));
            m_compatStaticAsteroids.Add("asteroid10moon1", new Vector3(1351.84424, -340.871521, -860.5213));
            m_compatStaticAsteroids.Add("asteroid10moon2", new Vector3(1441.8689, -265.305634, -741.8551));
            m_compatStaticAsteroids.Add("asteroid10moon3", new Vector3(1431.87585, -321.47998, -967.78595));
            m_compatStaticAsteroids.Add("asteroid10moon4", new Vector3(1480.02515, -322.488922, -812.282654));
            m_compatStaticAsteroids.Add("asteroid11", new Vector3(-183.633957, 466.912048, -661.5457));
            m_compatStaticAsteroids.Add("asteroid11moon0", new Vector3(-11.5127068, 753.9039, -555.280457));
            m_compatStaticAsteroids.Add("asteroid11moon1", new Vector3(-183.039, 568.8601, -495.7103));
            m_compatStaticAsteroids.Add("asteroid11moon2", new Vector3(-249.045959, 588.8494, -568.498169));
            m_compatStaticAsteroids.Add("asteroid11moon3", new Vector3(23.8666077, 697.3216, -618.337341));
            m_compatStaticAsteroids.Add("asteroid11moon4", new Vector3(-64.45533, 794.289368, -563.955566));
            m_compatStaticAsteroids.Add("asteroid12", new Vector3(1661.90222, -764.5163, -834.8348));
            m_compatStaticAsteroids.Add("asteroid12moon0", new Vector3(1746.53491, -508.546356, -559.888367));
            m_compatStaticAsteroids.Add("asteroid12moon1", new Vector3(1759.22644, -460.547882, -674.450745));
            m_compatStaticAsteroids.Add("asteroid12moon2", new Vector3(1902.05261, -646.29895, -521.436035));
            m_compatStaticAsteroids.Add("asteroid12moon3", new Vector3(1783.50293, -481.156219, -546.9324));
            m_compatStaticAsteroids.Add("asteroid12moon4", new Vector3(1922.93164, -536.1296, -514.729553));
            m_compatStaticAsteroids.Add("asteroid13", new Vector3(-554.702148, 680.6017, -1425.75684));
            m_compatStaticAsteroids.Add("asteroid13moon0", new Vector3(-247.824249, 658.906, -1189.49268));
            m_compatStaticAsteroids.Add("asteroid13moon1", new Vector3(-223.8683, 798.0059, -1253.07385));
            m_compatStaticAsteroids.Add("asteroid13moon2", new Vector3(-451.320862, 623.977539, -1223.93152));
            m_compatStaticAsteroids.Add("asteroid13moon3", new Vector3(-499.679932, 796.921753, -1202.13879));
            m_compatStaticAsteroids.Add("asteroid13moon4", new Vector3(-388.491455, 878.9669, -1172.26782));
            m_compatStaticAsteroids.Add("asteroid14", new Vector3(339.465454, 540.275452, -1189.011));
            m_compatStaticAsteroids.Add("asteroid14moon0", new Vector3(480.786316, 636.0764, -1039.763));
            m_compatStaticAsteroids.Add("asteroid14moon1", new Vector3(270.7714, 802.2115, -1126.12329));
            m_compatStaticAsteroids.Add("asteroid14moon2", new Vector3(418.871948, 670.8664, -1260.99463));
            m_compatStaticAsteroids.Add("asteroid14moon3", new Vector3(374.3302, 858.692932, -1049.71313));
            m_compatStaticAsteroids.Add("asteroid14moon4", new Vector3(482.535767, 743.1303, -998.006836));

            if (MyFakes.TEST_PREFABS_FOR_INCONSISTENCIES)
            {
                string prefabDir   = Path.Combine(MyFileSystem.ContentPath, "Data", "Prefabs");
                var    prefabFiles = Directory.GetFiles(prefabDir);
                foreach (var prefabFile in prefabFiles)
                {
                    if (Path.GetExtension(prefabFile) != ".sbc")
                    {
                        continue;
                    }

                    MyObjectBuilder_CubeGrid result = null;
                    var fsPath = Path.Combine(MyFileSystem.ContentPath, prefabFile);
                    Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_CubeGrid>(fsPath, out result);

                    if (result == null)
                    {
                        continue;
                    }

                    foreach (var block in result.CubeBlocks)
                    {
                        if (block.IntegrityPercent == 0.0f)
                        {
                            Debug.Assert(false, "Inconsistent block in prefab file " + prefabFile);
                            break;
                        }
                    }
                }

                string worldDir  = Path.Combine(MyFileSystem.ContentPath, "Worlds");
                var    worldDirs = Directory.GetDirectories(worldDir);
                foreach (var dir in worldDirs)
                {
                    var files = Directory.GetFiles(dir);
                    foreach (var file in files)
                    {
                        if (Path.GetExtension(file) != ".sbs")
                        {
                            continue;
                        }

                        MyObjectBuilder_Sector result = null;

                        var fsPath = Path.Combine(MyFileSystem.ContentPath, file);
                        Sandbox.Common.ObjectBuilders.Serializer.MyObjectBuilderSerializer.DeserializeXML <MyObjectBuilder_Sector>(fsPath, out result);

                        Debug.Assert(result != null, "Unloadable world: " + file);
                        foreach (var obj in result.SectorObjects)
                        {
                            if (obj.TypeId == typeof(MyObjectBuilder_CubeGrid))
                            {
                                var grid = (MyObjectBuilder_CubeGrid)obj;
                                foreach (var block in grid.CubeBlocks)
                                {
                                    if (block.IntegrityPercent == 0.0f)
                                    {
                                        Debug.Assert(false, "Inconsistent block in save " + file);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }