Esempio n. 1
0
		public BaseEntity( MyObjectBuilder_EntityBase baseEntity )
			: base( baseEntity )
		{
			if ( baseEntity != null )
			{
				m_entityId = baseEntity.EntityId;
				if ( baseEntity.PositionAndOrientation != null )
				{
					m_positionOrientation = baseEntity.PositionAndOrientation.GetValueOrDefault( );
				}
				else
				{
					m_positionOrientation = new MyPositionAndOrientation( );
					m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition( new Vector3D( -500000, -500000, -500000 ), new Vector3D( 500000, 500000, 500000 ) );
					m_positionOrientation.Forward = new Vector3( 0, 0, 1 );
					m_positionOrientation.Up = new Vector3( 0, 1, 0 );
				}
			}
			else
			{
				m_entityId = 0;
				m_positionOrientation = new MyPositionAndOrientation( );
				m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition( new Vector3( -500000, -500000, -500000 ), new Vector3( 500000, 500000, 500000 ) );
				m_positionOrientation.Forward = new Vector3( 0, 0, 1 );
				m_positionOrientation.Up = new Vector3( 0, 1, 0 );
			}

			m_linearVelocity = new Vector3( 0, 0, 0 );
			m_angularVelocity = new Vector3( 0, 0, 0 );
			m_maxLinearVelocity = (float)104.7;
		}
Esempio n. 2
0
        public override void Init(MyObjectBuilder_EntityBase builder)
        {
            var ob = (MyObjectBuilder_VoxelMap)builder;
            if (ob == null)
            {
                return;
            }

            m_storage = MyStorageBase.Load(ob.StorageName);
            
            //By Gregory: Added for compatibility with old saves
            if(m_storage == null)
            {
                return;
            }

            Init(builder, m_storage);

            if (ob.ContentChanged.HasValue)
            {
                ContentChanged = ob.ContentChanged.Value;
            }
            else
            {
                ContentChanged = true;
            }
        }
Esempio n. 3
0
        public StructureVoxelModel(MyObjectBuilder_EntityBase entityBase, string voxelPath)
            : base(entityBase)
        {
            if (voxelPath != null)
            {
                VoxelFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V2FileExtension);
                var previewFile = VoxelFilepath;

                if (!File.Exists(VoxelFilepath))
                {
                    var oldFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V1FileExtension);
                    if (File.Exists(oldFilepath))
                    {
                        SourceVoxelFilepath = oldFilepath;
                        previewFile = oldFilepath;
                        SpaceEngineersCore.ManageDeleteVoxelList.Add(oldFilepath);
                    }
                }

                ReadVoxelDetails(previewFile);
            }

            var materialList = SpaceEngineersCore.Resources.GetMaterialList().Select(m => m.Id.SubtypeName).OrderBy(s => s).ToList();

            GameMaterialList = new List<VoxelMaterialAssetModel>(materialList.Select(s => new VoxelMaterialAssetModel { MaterialName = s, DisplayName = s }));
            EditMaterialList = new List<VoxelMaterialAssetModel> { new VoxelMaterialAssetModel { MaterialName = null, DisplayName = "Delete/Remove" } };
            EditMaterialList.AddRange(materialList.Select(s => new VoxelMaterialAssetModel { MaterialName = s, DisplayName = s }));
        }
Esempio n. 4
0
        public StructureVoxelModel(MyObjectBuilder_EntityBase entityBase, string voxelPath)
            : base(entityBase)
        {
            var contentPath = ToolboxUpdater.GetApplicationContentPath();

            if (voxelPath != null)
            {
                VoxelFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V2FileExtension);
                var previewFile = VoxelFilepath;

                if (!File.Exists(VoxelFilepath))
                {
                    var oldFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V1FileExtension);
                    if (File.Exists(oldFilepath))
                    {
                        SourceVoxelFilepath = oldFilepath;
                        previewFile = oldFilepath;
                        SpaceEngineersCore.ManageDeleteVoxelList.Add(oldFilepath);
                    }
                }

                ReadVoxelDetails(previewFile);
            }

            var materialList = new Dictionary<string, string>();
            foreach (MyVoxelMaterialDefinition item in SpaceEngineersCore.Resources.VoxelMaterialDefinitions.OrderBy(m => m.Id.SubtypeName))
            {
                string texture = item.GetVoxelDisplayTexture();
                materialList.Add(item.Id.SubtypeName, texture == null ? null : SpaceEngineersCore.GetDataPathOrDefault(texture, Path.Combine(contentPath, texture)));
            }

            GameMaterialList = new List<VoxelMaterialAssetModel>(materialList.Select(m => new VoxelMaterialAssetModel { MaterialName = m.Key, DisplayName = m.Key, TextureFile = m.Value }));
            EditMaterialList = new List<VoxelMaterialAssetModel> { new VoxelMaterialAssetModel { MaterialName = null, DisplayName = "Delete/Remove" } };
            EditMaterialList.AddRange(materialList.Select(m => new VoxelMaterialAssetModel { MaterialName = m.Key, DisplayName = m.Key, TextureFile = m.Value }));
        }
Esempio n. 5
0
        public StructurePlanetModel(MyObjectBuilder_EntityBase entityBase, string voxelPath)
            : base(entityBase)
        {
            if (voxelPath != null)
            {
                VoxelFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V2FileExtension);
                var previewFile = VoxelFilepath;

                if (!File.Exists(VoxelFilepath))
                {
                    var oldFilepath = Path.Combine(voxelPath, Name + MyVoxelMap.V1FileExtension);
                    if (File.Exists(oldFilepath))
                    {
                        SourceVoxelFilepath = oldFilepath;
                        previewFile = oldFilepath;
                        SpaceEngineersCore.ManageDeleteVoxelList.Add(oldFilepath);
                    }
                }

                ReadVoxelDetails(previewFile);
            }
        }
Esempio n. 6
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            base.Init(objectBuilder);
            m_objectBuilder = objectBuilder;
            m_inhibitor     = Entity as IMyTerminalBlock;
            MaxRange        = Globals.Instance.RuntimeConfig[ModifierType.InhibitorRange];

            var parent = Entity as IMyCubeBlock;

            parent.OnUpgradeValuesChanged += UpgradeValuesChanged;
            parent.NeedsUpdate            |= MyEntityUpdateEnum.BEFORE_NEXT_FRAME;

            if (!parent.UpgradeValues.ContainsKey(ModifierType.InhibitorRange.ToString()))
            {
                parent.UpgradeValues.Add(ModifierType.InhibitorRange.ToString(), m_upgradeFactor);
            }
            (Entity as IMyTerminalBlock).AppendingCustomInfo += AppendingCustomInfo;
            (Entity as IMyTerminalBlock).PropertiesChanged   += PropertiesChanged;
            (Entity as IMyFunctionalBlock).EnabledChanged    += EnabledChanged;
            (Entity as IMyCubeBlock).IsWorkingChanged        += IsWorkingChanged;
            //(Entity as IMyPowerConsumer).PowerReceiver.SuppliedRatioChanged += PowerReceiver_SuppliedRatioChanged;
        }
 public StructureUnknownModel(MyObjectBuilder_EntityBase entityBase)
     : base(entityBase)
 {
 }
 public StructureInventoryBagModel(MyObjectBuilder_EntityBase entityBase)
     : base(entityBase)
 {
 }
Esempio n. 9
0
        public override void Init(MyObjectBuilder_EntityBase builder, Sandbox.Engine.Voxels.IMyStorage storage)
        {
            ProfilerShort.Begin("MyPlanet::Init()");
            if (MyFakes.ENABLE_PLANETS == false)
            {
                throw new PlanetsNotEnabledException();
            }

            ProfilerShort.Begin("MyVoxelBase Init");

            SyncFlag = true;

            base.Init(builder);

            ProfilerShort.BeginNextBlock("Load Saved Data");

            var ob = (MyObjectBuilder_Planet)builder;
            if (ob == null)
            {
                return;
            }

            if (ob.MutableStorage)
            {
                StorageName = ob.StorageName;
            }
            else
            {
                StorageName = string.Format("{0}", ob.StorageName);
            }

            m_planetInitValues.StorageName = StorageName;
            m_planetInitValues.PositionMinCorner = ob.PositionAndOrientation.Value.Position;
            m_planetInitValues.HasAtmosphere = ob.HasAtmosphere;
            m_planetInitValues.AtmosphereRadius = ob.AtmosphereRadius;
            m_planetInitValues.AtmosphereWavelengths = ob.AtmosphereWavelengths;
            m_planetInitValues.GravityFalloff = ob.GravityFalloff;
            m_planetInitValues.MarkAreaEmpty = ob.MarkAreaEmpty;
            m_planetInitValues.SurfaceGravity = ob.SurfaceGravity;
            m_planetInitValues.AddGps = ob.ShowGPS;
            m_planetInitValues.SpherizeWithDistance = ob.SpherizeWithDistance;
            m_planetInitValues.Generator = ob.PlanetGenerator == "" ? null : MyDefinitionManager.Static.GetDefinition<MyPlanetGeneratorDefinition>(MyStringHash.GetOrCompute(ob.PlanetGenerator));
            if (m_planetInitValues.Generator == null)
            {
                string message = string.Format("No definition found for planet generator {0}.", ob.PlanetGenerator);
                MyLog.Default.WriteLine(message);
                throw new Exception(message);
            }

            m_planetInitValues.AtmosphereSettings = m_planetInitValues.Generator.AtmosphereSettings.HasValue ? m_planetInitValues.Generator.AtmosphereSettings.Value : MyAtmosphereSettings.Defaults();
            m_planetInitValues.UserCreated = false;

            ProfilerShort.BeginNextBlock("Load Storage");
            if (storage != null)
            {
                m_planetInitValues.Storage = storage;
            }
            else
            {
                m_planetInitValues.Storage = MyStorageBase.Load(ob.StorageName);
            }

            m_planetInitValues.InitializeComponents = false;

            ProfilerShort.BeginNextBlock("Init Internal");
            Init(m_planetInitValues);
            ProfilerShort.End();

            ProfilerShort.End();
        }
Esempio n. 10
0
 abstract public void Init(MyObjectBuilder_EntityBase builder, Sandbox.Engine.Voxels.IMyStorage storage);
Esempio n. 11
0
        public virtual void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            ProfilerShort.Begin("MyEntity.Init(objectBuilder)");
            MarkedForClose = false;
            Closed = false;
            this.Render.PersistentFlags = MyPersistentEntityFlags2.CastShadows;

            if (objectBuilder != null)
            {
                if (objectBuilder.EntityId != 0)
                    this.EntityId = objectBuilder.EntityId;
                else
                    AllocateEntityID();

                DefinitionId = objectBuilder.GetId();

                if (objectBuilder.EntityDefinitionId != null) // backward compatibility
                {
                    Debug.Assert(objectBuilder.SubtypeName == null || objectBuilder.SubtypeName == objectBuilder.EntityDefinitionId.Value.SubtypeName);
                    DefinitionId = objectBuilder.EntityDefinitionId.Value;
                }

                if (objectBuilder.PositionAndOrientation.HasValue)
                {
                    var posAndOrient = objectBuilder.PositionAndOrientation.Value;

                    //GR: Check for NaN values and remove them (otherwise there will be problems wilth clusters)
                    if (posAndOrient.Position.x.IsValid() == false)
                    {
                        posAndOrient.Position.x = 0.0f;
                    }
                    if (posAndOrient.Position.y.IsValid() == false)
                    {
                        posAndOrient.Position.y = 0.0f;
                    }
                    if (posAndOrient.Position.z.IsValid() == false)
                    {
                        posAndOrient.Position.z = 0.0f;
                    }

                    MatrixD matrix = MatrixD.CreateWorld(posAndOrient.Position, posAndOrient.Forward, posAndOrient.Up);
                    //if (matrix.IsValid())
                    //    MatrixD.Rescale(ref matrix, scale);
                    MyUtils.AssertIsValid(matrix);
                    PositionComp.SetWorldMatrix((MatrixD)matrix);
                    ClampToWorld();
                }

                this.Name = objectBuilder.Name;
                this.Render.PersistentFlags = objectBuilder.PersistentFlags & ~VRage.ObjectBuilders.MyPersistentEntityFlags2.InScene;

                // This needs to be called after Entity has it's valid EntityID so components when are initiliazed or added to container, they get valid EntityID
                InitComponentsExtCallback(this.Components, DefinitionId.Value.TypeId, DefinitionId.Value.SubtypeId, objectBuilder.ComponentContainer);
            }
            else
            {
                AllocateEntityID();
            }

            Debug.Assert(!this.InScene, "Entity is in scene after creation!");

            MyEntitiesInterface.SetEntityName(this, false);

            if (SyncFlag)
            {
                CreateSync();
            }
            GameLogic.Init(objectBuilder);
            ProfilerShort.End();
        }
 public void ActivateVoxelClipboard(MyObjectBuilder_EntityBase voxelMap, IMyStorage storage, Vector3 centerDeltaDirection, float dragVectorLength)
 {
     MySessionComponentVoxelHand.Static.Enabled = false;
     m_voxelClipboard.SetVoxelMapFromBuilder(voxelMap, storage, centerDeltaDirection, dragVectorLength);
     this.Activate();
 }
Esempio n. 13
0
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            m_objectBuilder = objectBuilder;

            Door = Entity as IMyDoor;

            DoorsToCheck = new List<IMyDoor>();
            AirlockCodes = new List<string>();
            AirlockGroups = new List<string>();
            AirlockCounterGroups = new List<string>();

            DoorControl = DoorState.NO_CONTROLLED;
            Door.DoorStateChanged += Door_DoorStateChanged;
            DoorAutoControlTime = DateTime.MaxValue;
            Inited = false;
        }
 public void SubmitWork(MyObjectBuilder_EntityBase objectBuilder, bool addToScene, Action<MyEntity> doneHandler, MyEntity entity,List<MyObjectBuilder_EntityBase> subGridBuliders)
 {
     SubmitWork(new Item() { ObjectBuilder = objectBuilder, AddToScene = addToScene, DoneHandler = doneHandler, Result = entity, SubgridBuilders = subGridBuliders});
 }
Esempio n. 15
0
 public static string GetPrefabTypeName(MyObjectBuilder_EntityBase entity)
 {
     if (entity is MyObjectBuilder_VoxelMap)
         return "Asteroid";
     if (entity is MyObjectBuilder_CubeGrid)
     {
         var g = (MyObjectBuilder_CubeGrid)entity;
         if (g.IsStatic)
             return "Station";
         else if (g.GridSizeEnum == MyCubeSize.Large)
             return "LargeShip";
         else
             return "SmallShip";
     }
     if (entity is MyObjectBuilder_Character)
         return "Character";
     return "Unknown";
 }
Esempio n. 16
0
 public static void AddEntity(MyObjectBuilder_EntityBase entityBuilder)
 {
     MyEntities.CreateFromObjectBuilderAndAdd(entityBuilder);
 }
 IMyEntity IMyEntities.CreateFromObjectBuilderAndAdd(MyObjectBuilder_EntityBase objectBuilder)
 {
     return (IMyEntity)MyEntities.CreateFromObjectBuilderAndAdd(objectBuilder);
 }
 IMyEntity IMyEntities.CreateFromObjectBuilderNoinit(MyObjectBuilder_EntityBase objectBuilder)
 {
     return MyEntities.CreateFromObjectBuilderNoinit(objectBuilder);
 }
 void IMyEntities.RemapObjectBuilder(MyObjectBuilder_EntityBase objectBuilder)
 {
     MyEntities.RemapObjectBuilder(objectBuilder);
 }
Esempio n. 20
0
		public BaseEntity( MyObjectBuilder_EntityBase baseEntity, Object backingObject )
			: base( baseEntity, backingObject )
		{
			if ( baseEntity != null )
			{
				m_entityId = baseEntity.EntityId;
				if ( baseEntity.PositionAndOrientation != null )
				{
					m_positionOrientation = baseEntity.PositionAndOrientation.GetValueOrDefault( );
				}
				else
				{
					m_positionOrientation = new MyPositionAndOrientation( );
					m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition( new Vector3( -500000, -500000, -500000 ), new Vector3( 500000, 500000, 500000 ) );
					m_positionOrientation.Forward = new Vector3( 0, 0, 1 );
					m_positionOrientation.Up = new Vector3( 0, 1, 0 );
				}
			}
			else
			{
				m_entityId = 0;
				m_positionOrientation = new MyPositionAndOrientation( );
				m_positionOrientation.Position = UtilityFunctions.GenerateRandomBorderPosition( new Vector3( -500000, -500000, -500000 ), new Vector3( 500000, 500000, 500000 ) );
				m_positionOrientation.Forward = new Vector3( 0, 0, 1 );
				m_positionOrientation.Up = new Vector3( 0, 1, 0 );
			}

			m_networkManager = new BaseEntityNetworkManager( this, GetEntityNetworkManager( BackingObject ) );

			m_linearVelocity = new Vector3( 0, 0, 0 );
			m_angularVelocity = new Vector3( 0, 0, 0 );
			m_maxLinearVelocity = (float)104.7;

			if ( EntityId != 0 )
			{
				GameEntityManager.AddEntity( EntityId, this );
			}

			MySandboxGame.Static.Invoke( InternalRegisterEntityMovedEvent );
		}
Esempio n. 21
0
        public virtual void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            ProfilerShort.Begin("MyEntity.Init(objectBuilder)");
            MarkedForClose = false;
            Closed = false;
            this.Render.PersistentFlags = MyPersistentEntityFlags2.CastShadows;

            if (objectBuilder != null)
            {
                if (objectBuilder.EntityId != 0)
                    this.EntityId = objectBuilder.EntityId;
                else
                    AllocateEntityID();

                DefinitionId = objectBuilder.GetId();

                if (objectBuilder.EntityDefinitionId != null) // backward compatibility
                {
                    Debug.Assert(objectBuilder.SubtypeName == null || objectBuilder.SubtypeName == objectBuilder.EntityDefinitionId.Value.SubtypeName);
                    DefinitionId = objectBuilder.EntityDefinitionId.Value;
                }

                if (objectBuilder.PositionAndOrientation.HasValue)
                {
                    var posAndOrient = objectBuilder.PositionAndOrientation.Value;
                    MatrixD matrix = MatrixD.CreateWorld(posAndOrient.Position, posAndOrient.Forward, posAndOrient.Up);
                    MyUtils.AssertIsValid(matrix);

                    PositionComp.SetWorldMatrix((MatrixD)matrix);
                    ClampToWorld();
                }

                this.Name = objectBuilder.Name;
                this.Render.PersistentFlags = objectBuilder.PersistentFlags;

                // This needs to be called after Entity has it's valid EntityID so components when are initiliazed or added to container, they get valid EntityID
                InitComponentsExtCallback(this.Components, DefinitionId.Value.TypeId, DefinitionId.Value.SubtypeId, objectBuilder.ComponentContainer);
            }
            else
            {
                AllocateEntityID();
            }

            this.InScene = false;

            MyEntitiesInterface.SetEntityName(this, false);

            if (SyncFlag)
            {
                CreateSync();
            }
            GameLogic.Init(objectBuilder);
            ProfilerShort.End();
        }
Esempio n. 22
0
        public override void Init(MyObjectBuilder_EntityBase builder, IMyStorage storage)
        {
            ProfilerShort.Begin("base init");

            SyncFlag = true;

            base.Init(builder);
            base.Init(null, null, null, null, null);

            ProfilerShort.BeginNextBlock("Load file");

            var ob = (MyObjectBuilder_VoxelMap)builder;
            if (ob == null)
            {
                return;
            }
            if (ob.MutableStorage)
            {
                StorageName = ob.StorageName;
            }
            else
            {
                StorageName = GetNewStorageName(ob.StorageName);
            }

            m_storage = storage;
            m_storage.RangeChanged += storage_RangeChanged;
            m_storageMax = m_storage.Size;

            InitVoxelMap(MatrixD.CreateWorld((Vector3D)ob.PositionAndOrientation.Value.Position + Vector3D.TransformNormal((Vector3D)m_storage.Size / 2, WorldMatrix), WorldMatrix.Forward, WorldMatrix.Up), m_storage.Size);

            ProfilerShort.End();
        }
 public StructureFloatingObjectModel(MyObjectBuilder_EntityBase entityBase)
     : base(entityBase)
 {
 }
 public void SubmitWork(MyObjectBuilder_EntityBase objectBuilder, bool addToScene, Action<MyEntity> doneHandler, MyEntity entity = null)
 {
     SubmitWork(new Item() { ObjectBuilder = objectBuilder, AddToScene = addToScene, DoneHandler = doneHandler, Result = entity });
 }
Esempio n. 25
0
 void IMyVoxelMap.Init(MyObjectBuilder_EntityBase builder)
 {
     Init(builder);
 }
Esempio n. 26
0
 public override void Init(MyObjectBuilder_EntityBase objectBuilder)
 {
     base.Init(objectBuilder);
 }
        public override void Init(MyObjectBuilder_EntityBase objectBuilder)
        {
            var builder = objectBuilder as MyObjectBuilder_FloatingObject;
            if (builder.Item.Amount <= 0)
            {
                // I can only prevent creation of entity by throwing exception. This might cause crashes when thrown outside of MyEntities.CreateFromObjectBuilder().
                throw new ArgumentOutOfRangeException("MyPhysicalInventoryItem.Amount", string.Format("Creating floating object with invalid amount: {0}x '{1}'", builder.Item.Amount, builder.Item.PhysicalContent.GetId()));
            }
            base.Init(objectBuilder);

            this.Item = new MyPhysicalInventoryItem(builder.Item);
            this.m_modelVariant = builder.ModelVariant;

            InitInternal();

            NeedsUpdate |= MyEntityUpdateEnum.EACH_FRAME;

            UseDamageSystem = true;

            MyPhysicalItemDefinition itemDefinition = null;
            if (!MyDefinitionManager.Static.TryGetPhysicalItemDefinition(Item.GetDefinitionId(), out itemDefinition))
            {
                System.Diagnostics.Debug.Fail("Creating floating object, but it's physical item definition wasn't found! - " + Item.ItemId);
                ItemDefinition = null;
            }
            else
                ItemDefinition = itemDefinition;
            m_timeFromSpawn = MySession.Static.ElapsedPlayTime;
        }
        public void BuildEntities(out string[] sourceVoxelFiles, out MyObjectBuilder_EntityBase[] sourceEntities)
        {
            var entities = new List<MyObjectBuilder_EntityBase>();
            var sourceFiles = new List<string>();

            MainViewModel.ResetProgress(0, VoxelCollection.Count);

            foreach (var voxelDesign in VoxelCollection)
            {
                MainViewModel.Progress++;
                if (string.IsNullOrEmpty(voxelDesign.VoxelFile.SourceFilename) || !MyVoxelMap.IsVoxelMapFile(voxelDesign.VoxelFile.SourceFilename))
                    continue;


                var asteroid = new MyVoxelMap();
                string tempSourcefilename = null;

                switch (AsteroidFillType)
                {
                    case Support.AsteroidFillType.None:
                        asteroid.Load(voxelDesign.VoxelFile.SourceFilename, voxelDesign.MainMaterial.Value, false);
                        tempSourcefilename = voxelDesign.VoxelFile.SourceFilename;
                        break;

                    case AsteroidFillType.ByteFiller:
                        asteroid.Load(voxelDesign.VoxelFile.SourceFilename, voxelDesign.MainMaterial.Value, false);
                        var filler = new AsteroidByteFiller();
                        filler.FillAsteroid(asteroid, voxelDesign);
                        tempSourcefilename = TempfileUtil.NewFilename(MyVoxelMap.V2FileExtension);
                        asteroid.Save(tempSourcefilename);
                        break;
                }


                // automatically number all files, and check for duplicate filenames.
                var filename = MainViewModel.CreateUniqueVoxelStorageName(voxelDesign.VoxelFile.Name + MyVoxelMap.V2FileExtension, entities.ToArray());

                var radius = RandomUtil.GetDouble(MinimumRange, MaximumRange);
                var longitude = RandomUtil.GetDouble(0, 2 * Math.PI);
                var latitude = RandomUtil.GetDouble(-Math.PI / 2, (Math.PI / 2) + double.Epsilon);

                // Test data. Place asteroids items into a circle.
                //radius = 500;
                //longitude = Math.PI * 2 * ((double)voxelDesign.Index / VoxelCollection.Count);
                //latitude = 0;

                var x = radius * Math.Cos(latitude) * Math.Cos(longitude);
                var z = radius * Math.Cos(latitude) * Math.Sin(longitude);
                var y = radius * Math.Sin(latitude);

                var center = new Vector3D(CenterPositionX, CenterPositionY, CenterPositionZ);
                var position = center + new Vector3D(x, y, z) - asteroid.BoundingContent.Center;
                var entity = new MyObjectBuilder_VoxelMap(position, filename)
                {
                    EntityId = SpaceEngineersApi.GenerateEntityId(IDType.ASTEROID),
                    PersistentFlags = MyPersistentEntityFlags2.CastShadows | MyPersistentEntityFlags2.InScene,
                    StorageName = Path.GetFileNameWithoutExtension(filename),
                    PositionAndOrientation = new MyPositionAndOrientation
                    {
                        Position = position,
                        Forward = Vector3.Forward, // Asteroids currently don't have any orientation.
                        Up = Vector3.Up
                    }
                };

                entities.Add(entity);
                sourceFiles.Add(tempSourcefilename);
            }

            sourceVoxelFiles = sourceFiles.ToArray();
            sourceEntities = entities.ToArray();
        }
Esempio n. 29
0
 public override void Init(MyObjectBuilder_EntityBase builder)
 {
     Init(builder, null);
 }
 //Entities are usualy initialized from builder immediately after creation by factory
 public virtual void Init(MyObjectBuilder_EntityBase objectBuilder)
 {}
 public MyObjectBuilder_PhysicalGunObject(MyObjectBuilder_EntityBase gunEntity)
 {
     GunEntity = gunEntity;
 }