public void InitNavigationInfo(MyObjectBuilder_CubeBlockDefinition blockDef, string infoSubtypeId)
        {
            if (MyPerGameSettings.EnableAi)
            {
                if (infoSubtypeId == "Default")
                {
                    MyDefinitionManager.Static.SetDefaultNavDef(this);
                }
                else
                {
                    MyDefinitionId id = new MyDefinitionId(typeof(MyObjectBuilder_BlockNavigationDefinition), infoSubtypeId);
                    MyDefinitionManager.Static.TryGetDefinition(id, out NavigationDefinition);
                }

                if (NavigationDefinition != null && NavigationDefinition.Mesh != null)
                    NavigationDefinition.Mesh.MakeStatic();
            }
        }
 protected BlockDefinition(MyObjectBuilder_CubeBlockDefinition definition)
     : base(definition)
 {
 }
        private void InitEntityComponents(MyObjectBuilder_CubeBlockDefinition.EntityComponentDefinition[] entityComponentDefinitions)
        {
            if (entityComponentDefinitions == null) return;

            EntityComponents = new Dictionary<string, MyObjectBuilder_ComponentBase>(entityComponentDefinitions.Length);
            for (int i = 0; i < entityComponentDefinitions.Length; ++i)
            {
                var definition = entityComponentDefinitions[i];

                MyObjectBuilderType componentObType = MyObjectBuilderType.Parse(definition.BuilderType);
                Debug.Assert(!componentObType.IsNull, "Could not parse object builder type of component: " + definition.BuilderType);

                if (!componentObType.IsNull)
                {
                    var componentBuilder = MyObjectBuilderSerializer.CreateNewObject(componentObType) as MyObjectBuilder_ComponentBase;
                    Debug.Assert(componentBuilder != null, "Could not create object builder of type " + componentObType);
                    if (componentBuilder != null)
                    {
                        EntityComponents.Add(definition.ComponentType, componentBuilder);
                    }
                }
            }
        }
        private void InitMountPoints(MyObjectBuilder_CubeBlockDefinition def)
        {
            if (MountPoints != null)
                return;

            var center = (Size - 1) / 2;

            // Order of block sides: right, top, front, left, bottom, back
            // Right = +X;    Top = +Y; Front = +Z
            //  Left = -X; Bottom = -Y;  Back = -Z
            // Side origins are always in lower left when looking at the side from outside.
            const float OFFSET_CONST = 0.001f;
            const float THICKNESS_HALF = 0.0004f;

            if (!Context.IsBaseGame)
            {
                if (def.MountPoints != null && def.MountPoints.Length == 0)
                {
                    def.MountPoints = null;
                    string msg = "Obsolete default definition of mount points in " + def.Id;
                    MyDefinitionErrors.Add(Context, msg, ErrorSeverity.Warning);
                }
            }

            if (def.MountPoints == null)
            {
                // If there are no mount points defined, cover whole walls.
                List<MountPoint> mps = new List<MountPoint>(6);
                Vector3I normalRight, normalLeft, normalTop, normalBottom, normalFront, normalBack;
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[0], out normalRight);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[1], out normalTop);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[2], out normalFront);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[3], out normalLeft);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[4], out normalBottom);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[5], out normalBack);

                // Right and left walls
                {
                    Vector3 start = new Vector3(OFFSET_CONST, OFFSET_CONST, THICKNESS_HALF);
                    Vector3 end = new Vector3(Size.Z - OFFSET_CONST, Size.Y - OFFSET_CONST, -THICKNESS_HALF);
                    Vector3 s1, s2, e1, e2;
                    TransformMountPointPosition(ref start, 0, Size, out s1);
                    TransformMountPointPosition(ref end, 0, Size, out e1);
                    TransformMountPointPosition(ref start, 3, Size, out s2);
                    TransformMountPointPosition(ref end, 3, Size, out e2);
                    mps.Add(new MountPoint() { Start = s1, End = e1, Normal = normalRight });
                    mps.Add(new MountPoint() { Start = s2, End = e2, Normal = normalLeft });
                }

                // Top and bottom walls
                {
                    Vector3 start = new Vector3(OFFSET_CONST, OFFSET_CONST, THICKNESS_HALF);
                    Vector3 end = new Vector3(Size.X - OFFSET_CONST, Size.Z - OFFSET_CONST, -THICKNESS_HALF);
                    Vector3 s1, s2, e1, e2;
                    TransformMountPointPosition(ref start, 1, Size, out s1);
                    TransformMountPointPosition(ref end, 1, Size, out e1);
                    TransformMountPointPosition(ref start, 4, Size, out s2);
                    TransformMountPointPosition(ref end, 4, Size, out e2);
                    mps.Add(new MountPoint() { Start = s1, End = e1, Normal = normalTop });
                    mps.Add(new MountPoint() { Start = s2, End = e2, Normal = normalBottom });
                }

                // Front and back walls
                {
                    Vector3 start = new Vector3(OFFSET_CONST, OFFSET_CONST, THICKNESS_HALF);
                    Vector3 end = new Vector3(Size.X - OFFSET_CONST, Size.Y - OFFSET_CONST, -THICKNESS_HALF);
                    Vector3 s1, s2, e1, e2;
                    TransformMountPointPosition(ref start, 2, Size, out s1);
                    TransformMountPointPosition(ref end, 2, Size, out e1);
                    TransformMountPointPosition(ref start, 5, Size, out s2);
                    TransformMountPointPosition(ref end, 5, Size, out e2);
                    mps.Add(new MountPoint() { Start = s1, End = e1, Normal = normalFront });
                    mps.Add(new MountPoint() { Start = s2, End = e2, Normal = normalBack });
                }

                MountPoints = mps.ToArray();
                return;
            }
            else
            {
                var mpBuilders = def.MountPoints;
                MountPoints = new MountPoint[mpBuilders.Length];
                for (int i = 0; i < MountPoints.Length; ++i)
                {
                    var mpBuilder = mpBuilders[i]; // 'mp' stands for mount point
                    // I shrink mounts points a little to avoid overlaps when they are very close.
                    var mpStart  = new Vector3((Vector2)mpBuilder.Start + OFFSET_CONST, THICKNESS_HALF);
                    var mpEnd    = new Vector3((Vector2)mpBuilder.End - OFFSET_CONST, -THICKNESS_HALF);
                    var sideIdx  = (int)mpBuilder.Side;
                    var mpNormal = Vector3I.Forward;
                    TransformMountPointPosition(ref mpStart, sideIdx, Size, out mpStart);
                    TransformMountPointPosition(ref mpEnd, sideIdx, Size, out mpEnd);
                    Vector3I.TransformNormal(ref mpNormal, ref m_mountPointTransforms[sideIdx], out mpNormal);
                    MountPoints[i].Start          = mpStart;
                    MountPoints[i].End            = mpEnd;
                    MountPoints[i].Normal         = mpNormal;
                    MountPoints[i].ExclusionMask  = mpBuilder.ExclusionMask;
                    MountPoints[i].PropertiesMask = mpBuilder.PropertiesMask;
                }
            }
        }
        private void InitMountPoints(MyObjectBuilder_CubeBlockDefinition def)
        {
            if (MountPoints != null)
                return;

            var center = (Size - 1) / 2;


            if (!Context.IsBaseGame)
            {
                if (def.MountPoints != null && def.MountPoints.Length == 0)
                {
                    def.MountPoints = null;
                    string msg = "Obsolete default definition of mount points in " + def.Id;
                    MyDefinitionErrors.Add(Context, msg, ErrorSeverity.Warning);
                }
            }

            if (def.MountPoints == null)
            {
                // If there are no mount points defined, cover whole walls.
                List<MountPoint> mps = new List<MountPoint>(6);
                Vector3I normalRight, normalLeft, normalTop, normalBottom, normalFront, normalBack;
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[0], out normalRight);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[1], out normalTop);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[2], out normalFront);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[3], out normalLeft);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[4], out normalBottom);
                Vector3I.TransformNormal(ref Vector3I.Forward, ref m_mountPointTransforms[5], out normalBack);

                // Right and left walls
                {
                    Vector3 start = new Vector3(OFFSET_CONST, OFFSET_CONST, THICKNESS_HALF);
                    Vector3 end = new Vector3(Size.Z - OFFSET_CONST, Size.Y - OFFSET_CONST, -THICKNESS_HALF);
                    Vector3 s1, s2, e1, e2;
                    TransformMountPointPosition(ref start, 0, Size, out s1);
                    TransformMountPointPosition(ref end, 0, Size, out e1);
                    TransformMountPointPosition(ref start, 3, Size, out s2);
                    TransformMountPointPosition(ref end, 3, Size, out e2);
                    mps.Add(new MountPoint() { Start = s1, End = e1, Normal = normalRight, Enabled = true });
                    mps.Add(new MountPoint() { Start = s2, End = e2, Normal = normalLeft, Enabled = true });
                }

                // Top and bottom walls
                {
                    Vector3 start = new Vector3(OFFSET_CONST, OFFSET_CONST, THICKNESS_HALF);
                    Vector3 end = new Vector3(Size.X - OFFSET_CONST, Size.Z - OFFSET_CONST, -THICKNESS_HALF);
                    Vector3 s1, s2, e1, e2;
                    TransformMountPointPosition(ref start, 1, Size, out s1);
                    TransformMountPointPosition(ref end, 1, Size, out e1);
                    TransformMountPointPosition(ref start, 4, Size, out s2);
                    TransformMountPointPosition(ref end, 4, Size, out e2);
					mps.Add(new MountPoint() { Start = s1, End = e1, Normal = normalTop, Enabled = true });
					mps.Add(new MountPoint() { Start = s2, End = e2, Normal = normalBottom, Enabled = true });
                }

                // Front and back walls
                {
                    Vector3 start = new Vector3(OFFSET_CONST, OFFSET_CONST, THICKNESS_HALF);
                    Vector3 end = new Vector3(Size.X - OFFSET_CONST, Size.Y - OFFSET_CONST, -THICKNESS_HALF);
                    Vector3 s1, s2, e1, e2;
                    TransformMountPointPosition(ref start, 2, Size, out s1);
                    TransformMountPointPosition(ref end, 2, Size, out e1);
                    TransformMountPointPosition(ref start, 5, Size, out s2);
                    TransformMountPointPosition(ref end, 5, Size, out e2);
					mps.Add(new MountPoint() { Start = s1, End = e1, Normal = normalFront, Enabled = true });
					mps.Add(new MountPoint() { Start = s2, End = e2, Normal = normalBack, Enabled = true });
                }

                MountPoints = mps.ToArray();
                return;
            }
            else
            {
				Debug.Assert(m_tmpMounts.Count == 0);
				SetMountPoints(ref MountPoints, def.MountPoints, m_tmpMounts);

				if (def.BuildProgressModels != null)
				{
					for (int index = 0; index < def.BuildProgressModels.Count; ++index)
					{
						var defBuildProgressModel = BuildProgressModels[index];
						if (defBuildProgressModel == null)
							continue;

						var obBuildProgressModel = def.BuildProgressModels[index];
						if (obBuildProgressModel.MountPoints == null)
							continue;

						foreach (var mountPoint in obBuildProgressModel.MountPoints)
						{
							int sideId = (int)mountPoint.Side;
							if(!m_tmpIndices.Contains(sideId))
							{
								m_tmpMounts.RemoveAll((mount) => { return (int)mount.Side == sideId; });
								m_tmpIndices.Add(sideId);
							}
							m_tmpMounts.Add(mountPoint);
						}
						m_tmpIndices.Clear();
						defBuildProgressModel.MountPoints = new MountPoint[m_tmpMounts.Count];
						SetMountPoints(ref defBuildProgressModel.MountPoints, m_tmpMounts.ToArray(), null);
					}
				}
				m_tmpMounts.Clear();
            }
        }
		private void SetMountPoints(ref MountPoint[] mountPoints, MyObjectBuilder_CubeBlockDefinition.MountPoint[] mpBuilders, List<MyObjectBuilder_CubeBlockDefinition.MountPoint> addedMounts)
		{
			if(mountPoints == null)
				mountPoints = new MountPoint[mpBuilders.Length];
			for (int i = 0; i < mountPoints.Length; ++i)
			{
				var mpBuilder = mpBuilders[i];
				if(addedMounts != null)
					addedMounts.Add(mpBuilder);
				// shrink mount points a little to avoid overlaps when they are very close.
				var mpStart = new Vector3((Vector2)mpBuilder.Start + OFFSET_CONST, THICKNESS_HALF);
				var mpEnd = new Vector3((Vector2)mpBuilder.End - OFFSET_CONST, -THICKNESS_HALF);
				var sideIdx = (int)mpBuilder.Side;
				var mpNormal = Vector3I.Forward;
				TransformMountPointPosition(ref mpStart, sideIdx, Size, out mpStart);
				TransformMountPointPosition(ref mpEnd, sideIdx, Size, out mpEnd);
				Vector3I.TransformNormal(ref mpNormal, ref m_mountPointTransforms[sideIdx], out mpNormal);
				mountPoints[i].Start = mpStart;
				mountPoints[i].End = mpEnd;
				mountPoints[i].Normal = mpNormal;
				mountPoints[i].ExclusionMask = mpBuilder.ExclusionMask;
				mountPoints[i].PropertiesMask = mpBuilder.PropertiesMask;
				mountPoints[i].Enabled = mpBuilder.Enabled;
			}
		}
        private static InventoryEditorModel ParseInventory(MyObjectBuilder_Inventory inventory, MyObjectBuilder_CubeBlockDefinition definition = null)
        {
            if (inventory == null)
                return null;
            float volumeMultiplier = 1f; // Unsure if there should be a default of 1 if there isn't a InventorySize defined.

            if (definition == null)
                volumeMultiplier = 0.4f;
            else
            {
                var definitionType = definition.GetType();
                var invSizeField = definitionType.GetField("InventorySize");
                var inventoryMaxVolumeField = definitionType.GetField("InventoryMaxVolume");
                if (invSizeField != null)
                {
                    var invSize = (Vector3)invSizeField.GetValue(definition);
                    volumeMultiplier = invSize.X * invSize.Y * invSize.Z;
                }
                if (inventoryMaxVolumeField != null)
                {
                    var maxSize = (float)inventoryMaxVolumeField.GetValue(definition);
                    volumeMultiplier = MathHelper.Min(volumeMultiplier, maxSize);
                }
            }

            var settings = SpaceEngineersCore.WorldResource.Checkpoint.Settings;
            return new InventoryEditorModel(inventory, volumeMultiplier * 1000 * settings.InventorySizeMultiplier, null) { Name = inventory.InventoryFlags.ToString(), IsValid = true };
        }
		/// <summary>
		/// Method that fill the containers the underlayed definitions
		/// </summary>
		/// <param name="blocks">If an array is given, the containers will be filled with this array instead of the default underlayed one</param>
		public void FillOverLayerContainers(MyObjectBuilder_CubeBlockDefinition[] blocks)
		{
			m_cubeBlocks.Clear();
			m_assemblers.Clear();
			m_cargoContainers.Clear();
			m_cockpits.Clear();
			m_gravityGenerators.Clear();
			m_gyroscopes.Clear();
			m_mergeBlocks.Clear();
			m_motorStators.Clear();
			m_oreDetectors.Clear();
			m_reactors.Clear();
			m_refineries.Clear();
			m_lightingBlocks.Clear();
			m_shipDrills.Clear();
			m_solarPanels.Clear();
			m_thrusters.Clear();
			m_virtualMasses.Clear();
			foreach (var cubeBlock in blocks)
			{/*
				switch (cubeBlock.Id.TypeId)
				{
					case (MyObjectBuilderTypeEnum.CubeBlock):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Assembler):
					{
						m_assemblers.Add(new AssemblerDefinition((MyObjectBuilder_AssemblerDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Beacon):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.CargoContainer):
					{
						m_cargoContainers.Add(new CargoContainerDefinition((MyObjectBuilder_CargoContainerDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Cockpit):
					{
						m_cockpits.Add(new CockpitDefinition((MyObjectBuilder_CockpitDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Collector):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Conveyor):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.ConveyorConnector):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Decoy):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Door):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Drill):
					{
						m_shipDrills.Add(new ShipDrillDefinition((MyObjectBuilder_ShipDrillDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.GravityGenerator):
					{
						m_gravityGenerators.Add(new GravityGeneratorDefinition((MyObjectBuilder_GravityGeneratorDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Gyro):
					{
						m_gyroscopes.Add(new GyroscopeDefinition((MyObjectBuilder_GyroDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.LandingGear):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.LargeGatlingTurret):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.LightingBlock):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.MedicalRoom):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.MergeBlock):
					{
						m_mergeBlocks.Add(new MergeBlockDefinition((MyObjectBuilder_MergeBlockDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.MotorRotor):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.MotorStator):
					{
						m_motorStators.Add(new MotorStatorDefinition((MyObjectBuilder_MotorStatorDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.OreDetector):
					{
						m_oreDetectors.Add(new OreDetectorDefinition((MyObjectBuilder_OreDetectorDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Passage):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.RadioAntenna):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Reactor):
					{
						m_reactors.Add(new ReactorDefinition((MyObjectBuilder_ReactorDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.RealWheel):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Refinery):
					{
						m_refineries.Add(new RefineryDefinition((MyObjectBuilder_RefineryDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.ReflectorLight):
					{
						m_lightingBlocks.Add(new LightingBlockDefinition((MyObjectBuilder_LightingBlockDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.ShipConnector):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.ShipGrinder):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.ShipWelder):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.SmallGatlingGun):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.SmallMissileLauncher):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.SolarPanel):
					{
						m_solarPanels.Add(new SolarPanelDefinition((MyObjectBuilder_SolarPanelDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Thrust):
					{
						m_thrusters.Add(new ThrusterDefinition((MyObjectBuilder_ThrustDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.VirtualMass):
					{
						m_virtualMasses.Add(new VirtualMassDefinition((MyObjectBuilder_VirtualMassDefinition)cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Warhead):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;

					case (MyObjectBuilderTypeEnum.Wheel):
					{
						m_cubeBlocks.Add(new CubeBlockDef(cubeBlock));
					}
					break;
				}*/
			}
			m_pendingChanges = false;
		}
        //public static ObservableCollection<InventoryEditorModel> GetInventory(this MyObjectBuilder_EntityBase objectBuilderBase)
        //{
        //    var inventoryEditors = new ObservableCollection<InventoryEditorModel>();

        //    if (objectBuilderBase.ComponentContainer != null)
        //    {
        //        var inventoryBase = objectBuilderBase.ComponentContainer.Components.FirstOrDefault(e => e.TypeId == "MyInventoryBase");

        //        if (inventoryBase != null)
        //        {
        //            var singleInventory = inventoryBase.Component as MyObjectBuilder_Inventory;
        //            if (singleInventory != null)
        //            {
        //                var iem = ParseInventory(singleInventory);
        //                if (iem != null)
        //                    inventoryEditors.Add(iem);
        //            }

        //            var aggregate = inventoryBase.Component as MyObjectBuilder_InventoryAggregate;
        //            if (aggregate != null)
        //                foreach (var field in aggregate.Inventories)
        //                {
        //                    var iem = ParseInventory(field as MyObjectBuilder_Inventory);
        //                    if (iem != null)
        //                        inventoryEditors.Add(iem);
        //                }
        //        }
        //    }
        //    return inventoryEditors;
        //}

        public static ObservableCollection<InventoryEditorModel> GetInventory(this MyObjectBuilder_ComponentContainer componentContainer, MyObjectBuilder_CubeBlockDefinition definition = null)
        {
            var inventoryEditors = new ObservableCollection<InventoryEditorModel>();

            if (componentContainer != null)
            {
                var inventoryBase = componentContainer.Components.FirstOrDefault(e => e.TypeId == "MyInventoryBase");

                if (inventoryBase != null)
                {
                    var singleInventory = inventoryBase.Component as MyObjectBuilder_Inventory;
                    if (singleInventory != null)
                    {
                        var iem = ParseInventory(singleInventory, definition);
                        if (iem != null)
                            inventoryEditors.Add(iem);
                    }

                    var aggregate = inventoryBase.Component as MyObjectBuilder_InventoryAggregate;
                    if (aggregate != null)
                        foreach (var field in aggregate.Inventories)
                        {
                            var iem = ParseInventory(field as MyObjectBuilder_Inventory, definition);
                            if (iem != null)
                                inventoryEditors.Add(iem);
                        }
                }
            }
            return inventoryEditors;
        }
Example #10
0
 public MyObjectBuilder_CubeBlock CreateCube(MyObjectBuilderType typeId, string subTypeId, MyObjectBuilder_CubeBlockDefinition definition)
 {
     return _dataModel.CreateCube(typeId, subTypeId, definition);
 }
Example #11
0
 public CubeItemModel(MyObjectBuilder_CubeBlock cube, MyObjectBuilder_CubeBlockDefinition definition)
 {
     SetProperties(cube, definition);
 }
Example #12
0
        private void SetProperties(MyObjectBuilder_CubeBlock cube, MyObjectBuilder_CubeBlockDefinition definition)
        {
            Cube = cube;
            Position = new BindablePoint3DIModel(cube.Min);
            SetColor(cube.ColorMaskHSV);
            BuildPercent = cube.BuildPercent;

            if (definition == null)
            {
                // Obsolete block or Mod not loaded.
                return;
            }

            CubeSize = definition.CubeSize;
            FriendlyName = SpaceEngineersApi.GetResourceName(definition.DisplayName);

            var identity = SpaceEngineersCore.WorldResource.Checkpoint.Identities.FirstOrDefault(p => p.PlayerId == Owner);
            var dead = " (dead)";
            if (SpaceEngineersCore.WorldResource.Checkpoint.AllPlayersData != null)
            {
                var player = SpaceEngineersCore.WorldResource.Checkpoint.AllPlayersData.Dictionary.FirstOrDefault(kvp => kvp.Value.IdentityId == Owner);
                dead = player.Value == null ? " (dead)" : "";
            }
            OwnerName = identity == null ? null : identity.DisplayName + dead;
            TypeId = definition.Id.TypeId;
            SubtypeId = definition.Id.SubtypeId;

            if (Inventory == null)
                Inventory = new ObservableCollection<InventoryEditorModel>();

            foreach (var item in cube.ComponentContainer.GetInventory(definition))
                Inventory.Add(item);

            while (Inventory.Count < 2)
            {
                Inventory.Add(new InventoryEditorModel(false));
            }
        }
Example #13
0
        public MyObjectBuilder_CubeBlock CreateCube(MyObjectBuilderType typeId, string subTypeId, MyObjectBuilder_CubeBlockDefinition definition)
        {
            var newCube = SpaceEngineersCore.Resources.CreateNewObject<MyObjectBuilder_CubeBlock>(typeId, subTypeId);
            newCube.BlockOrientation = Cube.BlockOrientation;
            newCube.ColorMaskHSV = Cube.ColorMaskHSV;
            newCube.BuildPercent = Cube.BuildPercent;
            newCube.EntityId = Cube.EntityId;
            newCube.IntegrityPercent = Cube.IntegrityPercent;
            newCube.Min = Cube.Min;

            SetProperties(newCube, definition);

            return newCube;
        }