New option under "Create" to "Generate Asteroid Belt"
还没有人认领这个 Issue。
评估
调研方向
首先定位现有的 BuildEntities 方法,以及 issue 中描述的 UI 入口 Create 和 Generate Asteroid Field。阅读当前小行星带如何收集参数并构建实体,然后定义带状区域对话框和坐标生成逻辑,使保存的世界在指定半径内包含所请求数量的小行星;验证所述的高数量警告。
由索引模型根据 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 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
midspace/SEToolbox 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 25/100
-
难度 4/5 3-5 天 新手友好度 15/100
-
Crash on Replace未关闭
难度 4/5 3-5 天 新手友好度 25/100
查看 midspace/SEToolbox 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 74/100
维护者通常 2 天内回复
-
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 天内回复