static void SpawnAsteroidConfirmedSuccess(ref SpawnAsteroidConfirmedMsg msg, MyNetworkClient sender) { MyStorageBase storage; SpawnAsteroidMsg asteroid = msg.AsteroidDetails; string storageName; using (MyRandom.Instance.PushSeed(asteroid.RandomSeed)) { if (!asteroid.IsProcedural) { var storageNameBase = asteroid.StorageName ?? (asteroid.Asteroid + "-" + asteroid.RandomSeed); storageName = MakeStorageName(storageNameBase); storage = CreateAsteroidStorage(asteroid.Asteroid, asteroid.RandomSeed); } else { var storageNameBase = asteroid.StorageName ?? "ProcAsteroid" + "-" + asteroid.RandomSeed + "r" + asteroid.ProceduralRadius; storageName = MakeStorageName(storageNameBase); storage = CreateProceduralAsteroidStorage(asteroid.RandomSeed, asteroid.ProceduralRadius, 0.03f); } } var pastedVoxelMap = new MyVoxelMap(); pastedVoxelMap.EntityId = msg.EntityId; pastedVoxelMap.Init(storageName, storage, asteroid.Position - storage.Size * 0.5f); MyEntities.Add(pastedVoxelMap); }
static void SpawnAsteroidSuccess(ref SpawnAsteroidMsg msg, MyNetworkClient sender) { SpawnAsteroidConfirmedMsg response; response.AsteroidDetails = msg; response.EntityId = MyEntityIdentifier.AllocateId(); Sync.Layer.SendMessageToAllAndSelf(ref response, MyTransportMessageEnum.Success); }
private void SpawnProceduralAsteroid(int seed, float radius) { var storageNameBase = "ProcAsteroid" + "-" + seed + "r" + radius; var storageName = MakeStorageName(storageNameBase); var storage = CreateProceduralAsteroidStorage(seed, radius); var builder = CreateAsteroidObjectBuilder(storageName); m_lastAsteroidMsg = new SpawnAsteroidMsg() { RandomSeed = seed, Position = Vector3D.Zero, StorageName = storageName, IsProcedural = true, ProceduralRadius = radius }; MyCubeBuilder.Static.ActivateVoxelClipboard(builder, storage, MySector.MainCamera.ForwardVector, (storage.Size * 0.5f).Length()); }
private void SpawnVoxelPreview() { var randomSeed = MyRandom.Instance.CreateRandomSeed(); using (MyRandom.Instance.PushSeed(randomSeed)) { var storageNameBase = m_selectedCoreVoxelFile + "-" + randomSeed; String storageName = MakeStorageName(storageNameBase); var storage = CreateAsteroidStorage(m_selectedCoreVoxelFile, randomSeed); var builder = CreateAsteroidObjectBuilder(storageName); m_lastAsteroidMsg = new SpawnAsteroidMsg() { Asteroid = m_selectedCoreVoxelFile.ToString(), RandomSeed = randomSeed, Position = Vector3D.Zero, StorageName = storageName, IsProcedural = false }; MyCubeBuilder.Static.ActivateVoxelClipboard(builder, storage, MySector.MainCamera.ForwardVector, (storage.Size * 0.5f).Length()); } }