Beispiel #1
0
        public void Edit()
        {
            if (this.asteroid != null)
            {
                if (ImGui.Button("Regenerate"))
                {
                    this.EntityController.DestroyEntity(this.asteroid.Entity);
                    this.Generate();
                }

                ImGui.Separator();

                if (ImGui.SliderFloat("Rim Width", ref this.rimWidth, 0.0f, 10.0f) ||
                    ImGui.SliderFloat("Rim Steepness", ref this.rimSteepness, 0.01f, 1.0f) ||
                    ImGui.Button("Apply Noise"))
                {
                    var craters = this.GenerateCraters();
                    this.NoiseGenerator.GenerateNoise(this.asteroid,
                                                      new NoiseSettings()
                    {
                        rimWidth     = rimWidth,
                        rimSteepness = rimSteepness,
                        craterCount  = craters.Length
                    },
                                                      craters
                                                      );
                }
            }
            else
            {
                if (ImGui.Button("Generate"))
                {
                    this.Generate();
                }
            }

            if (ImGui.TreeNode("Asteroid"))
            {
                ObjectEditor.Create(this.Editors, this.AsteroidBluePrint);
                ImGui.TreePop();
            }
            for (var i = 0; i < this.CraterBluePrints.Count; i++)
            {
                if (ImGui.TreeNode($"Crater {i}"))
                {
                    ObjectEditor.Create(this.Editors, this.CraterBluePrints[i]);
                    ImGui.TreePop();
                }
            }
        }
Beispiel #2
0
        private void WriteEntityComponents(Entity entity)
        {
            this.Components.Clear();
            this.ComponentSearcher.GetComponents(entity, this.Components);
            Parent parent = null;

            for (var i = 0; i < this.Components.Count; i++)
            {
                var component = this.Components[i];
                // ImGui requires a unique name for every node, so for each component we add
                // check how many of that component we've already added and use that in the name
                var count = this.Count(component);

                var name = GetName(component);

                if (component is Parent p)
                {
                    parent = p;
                }
                else if (ImGui.TreeNode(name + " #" + count.ToString("00")))
                {
                    ObjectEditor.Create(this.Editors, component);

                    if (ImGui.Button("Remove Component"))
                    {
                        var container = this.ComponentSearcher.GetContainer(component);
                        container.Remove(this.EntityState.SelectedEntity);
                    }
                    ImGui.TreePop();
                }
            }

            if (parent != null)
            {
                if (ImGui.TreeNode("Children"))
                {
                    for (var i = 0; i < parent.Children.Count; i++)
                    {
                        var child = parent.Children[i];
                        if (ImGui.TreeNode($"{child}"))
                        {
                            this.WriteEntityComponents(child);
                            ImGui.TreePop();
                        }
                    }

                    ImGui.TreePop();
                }
            }
        }