Exemple #1
0
        public static IMyVoxelMap SpawnAsteroid(MyPositionAndOrientation pos, CompositeShapeProviderBuilder provider)
        {
            var       storage     = new OctreeStorageBuilder(provider, MyVoxelCoordSystems.FindBestOctreeSize(provider.Size));
            var       storageName = $"proc_astr_{provider.Seed}_{provider.Size}_{(long) pos.Position.X}_{(long) pos.Position.Y}_{(long) pos.Position.Z}";
            var       entityID    = GetAsteroidEntityId(storageName);
            IMyEntity currEntity;

            if (MyAPIGateway.Entities.TryGetEntityById(entityID, out currEntity))
            {
                return(currEntity as IMyVoxelMap);
            }
            var data = storage.GetCompressedData();

            var storageInstance = MyAPIGateway.Session.VoxelMaps.CreateStorage(data);
            var entity          = MyAPIGateway.Session.VoxelMaps.CreateVoxelMap(storageName, storageInstance, pos.Position, entityID);

            entity.Save = false;
            var realEntity = entity as MyEntity;

            if (realEntity == null)
            {
                return(entity);
            }
            MyEntities.RaiseEntityCreated(realEntity);
            MyEntities.Add(realEntity);
            return(entity);
        }
Exemple #2
0
        public static CompositeShapeProviderBuilder CreateAsteroidShape(int seed, float size, int generatorEntry)
        {
            if (generatorEntry > AsteroidGeneratorCount - 1)
            {
                generatorEntry = AsteroidGeneratorCount - 1;
            }
            else if (generatorEntry < 0)
            {
                generatorEntry = 0;
            }

            var gen    = AsteroidShapeGenerator.AsteroidGenerators[generatorEntry];
            var result = new CompositeShapeProviderBuilder
            {
                Version      = CURRENT_VERSION,
                Generator    = generatorEntry,
                Seed         = seed,
                Size         = size,
                UnusedCompat = 0
            };

            gen(seed, size, out result.GeneratedData);
            return(result);
        }
Exemple #3
0
 public static CompositeShapeProviderBuilder CreateProceduralAsteroidProvider(int seed, float radius)
 {
     return(CompositeShapeProviderBuilder.CreateAsteroidShape(seed, radius, 2));
 }