Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

New option under "Create" to "Generate Asteroid Belt"

Đang mở
#116 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
csharp
Lĩnh vực
game-dev

Hướng nghiên cứu

Bắt đầu bằng cách xác định phương thức BuildEntities hiện có và các điểm vào UI Create và Generate Asteroid Field được mô tả trong issue. Đọc cách các trường tiểu hành tinh hiện tại thu thập tham số và xây dựng các thực thể, sau đó định nghĩa hộp thoại vành đai cùng việc tạo tọa độ để một world đã lưu chứa số lượng tiểu hành tinh được yêu cầu trong bán kính đã chỉ định; xác thực cảnh báo về số lượng cao đã nêu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
C#
Star
156
Fork
61
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của midspace/SEToolbox

Tất cả issue của midspace/SEToolbox

Issue tương tự

Thêm issue về C#

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.