示例#1
0
        public static void SetDefaults()
        {
            MySolarSystemArea defaults = MySolarSystemConstants.GetDefaultArea();

            SunProperties          = defaults.SectorData.SunProperties;
            FogProperties          = defaults.SectorData.FogProperties;
            DebrisProperties       = defaults.SectorData.DebrisProperties;
            ImpostorProperties     = defaults.SectorData.ImpostorProperties;
            ParticleDustProperties = defaults.SectorData.ParticleDustProperties;
            GodRaysProperties      = defaults.SectorData.GodRaysProperties;
            BackgroundTexture      = defaults.SectorData.BackgroundTexture;
        }
        public void GenerateSectorObjectBuildersFromSolarEntities(List<MySolarSystemMapEntity> entities, List<MyMwcObjectBuilder_Base> addToList, Random rnd, MyWeightDictionary<MyMwcVoxelMaterialsEnum> primaryMaterials, MyWeightDictionary<MyMwcVoxelMaterialsEnum> secondaryMaterials, MyStaticAsteroidTypeSetEnum staticAsteroidTypesets, MyMwcVoxelMaterialsEnum? fieldMaterial = null, MySolarSystemArea.AreaEnum? areaType = null)
        {
            List<MyMwcObjectBuilder_StaticAsteroid_TypesEnum> asteroids = new List<MyMwcObjectBuilder_StaticAsteroid_TypesEnum>(5);
            List<MyMwcVoxelFilesEnum> voxelAsteroids = new List<MyMwcVoxelFilesEnum>(10);

            int count = addToList.Count;

            foreach (var e in entities)
            {
                if (e.EntityType == MySolarSystemEntityEnum.VoxelAsteroid)
                {
                    int voxelAsteroidSize = FindAsteroidSize(e.Radius, MyVoxelMap.AsteroidSizes);

                    int rndIndex = rnd.Next(0, voxelAsteroids.Count);

                    MyVoxelMap.GetAsteroidsBySizeInMeters(voxelAsteroidSize, voxelAsteroids, false);

                    MyMwcObjectBuilder_VoxelMap builder = GenerateVoxelMap(voxelAsteroidSize, e.PositionInSector, rnd, voxelAsteroids, primaryMaterials, secondaryMaterials);

                    addToList.Add(builder);
                }
                else if (e.EntityType == MySolarSystemEntityEnum.StaticAsteroid)
                {
                    float radius = 100;
                    if (e.Radius == 10000)
                        radius = rnd.Next(2000, 11000);
                    if (e.Radius == 1000)
                        radius = rnd.Next(100, 1100);
                    if (e.Radius == 100)
                        radius = rnd.Next(10, 100);


                    MyMwcVoxelMaterialsEnum asteroidMaterial = MyMwcVoxelMaterialsEnum.Stone_01;
                    if (primaryMaterials.Count > 0)
                        primaryMaterials.GetRandomItem(rnd);

                    MyStaticAsteroidTypeSetEnum asteroidType = MyStaticAsteroidTypeSetEnum.A;

                    //for (int i = 0; i < 40000000; i++)
                    {
                        asteroidType = (MyStaticAsteroidTypeSetEnum)rnd.Item(Enum.GetValues(typeof(MyStaticAsteroidTypeSetEnum)));
                    }

                    if ((staticAsteroidTypesets & MyStaticAsteroidTypeSetEnum.A) == MyStaticAsteroidTypeSetEnum.A)
                        asteroidType = MyStaticAsteroidTypeSetEnum.A;
                    if ((staticAsteroidTypesets & MyStaticAsteroidTypeSetEnum.B) == MyStaticAsteroidTypeSetEnum.B)
                        asteroidType = MyStaticAsteroidTypeSetEnum.B;
                    if ((staticAsteroidTypesets & MyStaticAsteroidTypeSetEnum.All) == MyStaticAsteroidTypeSetEnum.All)
                        asteroidType = rnd.Float(0, 1) > 0.5f ? MyStaticAsteroidTypeSetEnum.A : MyStaticAsteroidTypeSetEnum.B;

                    var builder = GenerateStaticAsteroid(radius, asteroidType, asteroidMaterial, e.PositionInSector, rnd, asteroids);

  
                    builder.AsteroidMaterial1 = fieldMaterial;
                    if (areaType == MySolarSystemArea.AreaEnum.Sun)
                    {
                        builder.FieldDir = MinerWars.AppCode.Game.GUI.MyGuiScreenGamePlay.Static.GetDirectionToSunNormalized();
                    }

                    builder.Generated = true;
                    addToList.Add(builder);

                 
                    //MyEntity ent = MyEntities.CreateFromObjectBuilderAndAdd(null, new MyMwcObjectBuilder_StaticAsteroid(asteroids[rndIndex], mat),
                    //    Matrix.CreateWorld(e.PositionInSector, rnd.Vector(1), rnd.Vector(1)));
                }
                else if (e.EntityType == MySolarSystemEntityEnum.LargeShip)
                {
                    var shipType = rnd.Enum<MyMwcObjectBuilder_PrefabLargeShip_TypesEnum>();
                    MyMwcObjectBuilder_Prefab_AppearanceEnum appearance = rnd.Enum<MyMwcObjectBuilder_Prefab_AppearanceEnum>();

                    var ship = new MyMwcObjectBuilder_PrefabLargeShip(shipType, appearance, new MyMwcVector3Short(0, 0, 0), rnd.Vector(1), null, rnd.FloatNormal(), "Abandoned large ship", 0, false, 0);                    
                    var gamePlayProperties = MyGameplayConstants.GetGameplayProperties(MyMwcObjectBuilderTypeEnum.PrefabLargeShip, (int)shipType, MyMwcObjectBuilder_FactionEnum.Euroamerican);
                    ship.PrefabHealthRatio = MyGameplayConstants.HEALTH_RATIO_MAX;
                    ship.PrefabMaxHealth = gamePlayProperties.MaxHealth;
                    var prefabs = new List<MyMwcObjectBuilder_PrefabBase>();
                    prefabs.Add(ship);
                    var container = new MyMwcObjectBuilder_PrefabContainer(0, MyMwcObjectBuilder_PrefabContainer_TypesEnum.INSTANCE, prefabs, 0, rnd.Enum<MyMwcObjectBuilder_FactionEnum>(), null);
                    container.PositionAndOrientation = new MyMwcPositionAndOrientation(e.PositionInSector, Vector3.Forward, Vector3.Up);
                    addToList.Add(container);
                }
                else if (e.EntityType == MySolarSystemEntityEnum.DebrisField)
                {
                    MyMwcObjectBuilder_LargeDebrisField objectBuilder = new MyMwcObjectBuilder_LargeDebrisField(MyMwcObjectBuilder_LargeDebrisField_TypesEnum.Debris84);
                    objectBuilder.PositionAndOrientation = new MyMwcPositionAndOrientation(e.PositionInSector, rnd.Vector(1), rnd.Vector(1));
                    addToList.Add(objectBuilder);
                }
            }
        }