New option under "Create" to "Generate Asteroid Belt"
まだ誰も着手していません。
評価
調査の方向性
まず、既存の BuildEntities メソッドと、issue に記載されている UI の Create および Generate Asteroid Field のエントリーポイントを見つけます。現在の asteroid field がどのようにパラメーターを収集してエンティティを構築しているかを読み、その後、保存されたワールドに指定された半径内で要求された数の asteroid が含まれるように、belt ダイアログと座標生成を定義します。指定された高カウント時の警告を検証します。
索引モデルが issue の本文から書いたものです。
説明
I have been looking for a while on how to generate an asteroid belt in space engineers. After some research there was no good way to do this other then really generate all those asteroids. Whereas with your program it can already generate asteroid fields. It ook me some time as a junior software engineer to find the specific code in your source code which was generating the astroids.
As I understood The method "BuildEntities" will build all the entities created in the pop-up windows. which triggers on create button event.
I kindly ask if you would like to implement this feature where the only thing still needed to be done is a new pop-up window. Which differs from "generate asteroid field" it would require the following parameters: Center (x, y, z coordinates), Radius (the distant from the center where the belt will be created), amount of asteroid (I would recommend using your already written random generate astroid in a loop function to generate the amount of asteroid. this in turn will result in how dense the astroid belt will be.
public void BuildEntitiesBelt(out string[] sourceVoxelFiles, out MyObjectBuilder_EntityBase[] sourceEntities)
{
var entities = new List<MyObjectBuilder_EntityBase>();
var sourceFiles = new List<string>();
var AsteroidCount = VoxelCollection.Count;
MainViewModel.ResetProgress(0, AsteroidCount);
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());
Random random = new Random()
var x = CenterPositionX + radius * Math.cos(2 * Math.PI * i / AsteroidCount);
var y = CenterPositionY + radius * Math.sin(2 * Math.PI * i / AsteroidCount);
var z = CenterPositionZ + random.Next(-4000, 4000);
x+= random.Next(-2000, 2000);
y+= random.Next(-2000, 2000);
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();
}
This code is almost an exact copy of yours but with some slight changes in how the coordinates are calculated. It's up to you if you want two sperate methods or just a simple if statement checking if you are generating asteroid field or belt.
I haven't created a pop-up yet. If you don't have time I will try to make it myself. but as I said I'm still learning to code.
Hope this will help the community as some people are looking to generate an asteroid belt which this will be able to do.
If I missed anything thing or you would like some more information, I'm keen to hear from you!
Also let me know what you think of this feature!
Sidenote: put a warning that if you go a higher number then 10000 asteroid it will decrease load time of said save world.
- 主要言語
- C#
- スター
- 156
- フォーク
- 61
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
midspace/SEToolbox のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
-
1.202.120.1 Errorオープン
難易度 4/5 3〜5日 初心者へのやさしさ 15/100
-
Crash on Replaceオープン
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
midspace/SEToolbox の issue をすべて見る
似ている issue
-
bug effort:S P3
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
nightscout/nocturne#3093 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100