public void UiLayout()
        {
            ImGui.Begin("Steering Behaviors");

            ImGui.TextWrapped("Choose a steering behavior to add:");

            if (ImGui.Button("DESTROY ALL"))
            {
                var entities = Core.Scene.FindEntitiesWithTag(123);
                foreach (var entity in entities)
                {
                    entity.Destroy();
                }
            }
            if (ImGui.Button("DELETE OBSTACLES"))
            {
                var entities = Core.Scene.FindEntitiesWithTag(111);
                foreach (var entity in entities)
                {
                    entity.Destroy();
                }
            }
            if (ImGui.Button("DELETE PATH NODES"))
            {
                _pathBuilder.Path.Clear();
            }

            if (ImGui.CollapsingHeader("Default Parameters"))
            {
                var mass        = _params.Mass.Value;
                var maxForce    = _params.MaxForce.Value;
                var maxVelocity = _params.MaxVelocity.Value;

                ImGui.DragFloat("Mass", ref mass, 0.1f);
                ImGui.DragFloat("Max Force", ref maxForce, 0.1f);
                ImGui.DragFloat("Max Velocity", ref maxVelocity, 0.1f);

                if (Math.Abs(mass - _params.Mass.Value) > 0.001f)
                {
                    _params.Mass = mass;
                }
                if (Math.Abs(maxForce - _params.MaxForce.Value) > 0.001f)
                {
                    _params.MaxForce = maxForce;
                }
                if (Math.Abs(maxVelocity - _params.MaxVelocity.Value) > 0.001f)
                {
                    _params.MaxVelocity = maxVelocity;
                }
            }
            //ImGui.Separator();

            if (ImGui.CollapsingHeader("Seek##1"))
            {
                ImGui.TextWrapped("Seek: the most simple steering behavior, only seeking the target");
                if (ImGui.Button("Add Seek"))
                {
                    AddSeek();
                }
            }
            //ImGui.Separator();

            if (ImGui.CollapsingHeader("Flee##1"))
            {
                ImGui.TextWrapped("Flee: the counter of Seek - flee away from the target");
                if (ImGui.Button("Add Flee"))
                {
                    AddFlee();
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Arrival##1"))
            {
                ImGui.TextWrapped(
                    "Arrival: a seeker with arrival radius which the more slows down the nearer to the target");
                if (ImGui.Button("Add Arrival"))
                {
                    AddArrival();
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Wander##1"))
            {
                ImGui.TextWrapped("Wander: just wanders around in random manner");
                if (ImGui.Button("Wander x1"))
                {
                    AddWander();
                }

                ImGui.SameLine();
                if (ImGui.Button("Wander x10"))
                {
                    AddWander(10);
                }

                ImGui.SameLine();
                if (ImGui.Button("Wander x20"))
                {
                    AddWander(20);
                }

                ImGui.SameLine();
                if (ImGui.Button("Wander x100"))
                {
                    AddWander(100);
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Pursuit##1"))
            {
                ImGui.TextWrapped("Pursuit: hunting the target down with kind of prediction");
                if (ImGui.Button("Pursuit"))
                {
                    AddPursuit();
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Evade##1"))
            {
                ImGui.TextWrapped(
                    "Evade: the opposite of pursuit - just like Flee - getting away from the target with some kind of prediction");
                if (ImGui.Button("Evade"))
                {
                    AddEvade();
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Collision Avoidance##1"))
            {
                ImGui.TextWrapped("Collision Avoidance: trying to avoid obstacles");
                ImGui.TextWrapped("Pro tip: use left mouse button to place obstacles");
                if (ImGui.Button("Collision Avoidance"))
                {
                    AddCollisionAvoidance();
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Path Following##1"))
            {
                ImGui.TextWrapped("Path Following: just as simple as that, following the path with 'natural' movement");
                if (ImGui.Button("Path Following"))
                {
                    AddPathFollowing();
                }
                int newMode = _imGuiMode;
                ImGui.Text("Path Following Mode:");
                ImGui.ListBox("", ref newMode, new[] { "One Way", "Circular", "Patrol" }, 3);

                if (newMode != _imGuiMode)
                {
                    _imGuiMode        = newMode;
                    PathFollowingMode = (PathFollowingMode)_imGuiMode;
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Leader Following##1"))
            {
                ImGui.TextWrapped(
                    "Leader Following: a composition of other steering forces, all arranged to make a group of characters follow a specific character");
                if (ImGui.Button("Leader Following"))
                {
                    AddLeaderFollowing();
                }
            }
            ImGui.Separator();

            if (ImGui.CollapsingHeader("Queue##1"))
            {
                ImGui.TextWrapped(
                    "Queue: process of standing in line, forming a row of characters that are patiently waiting to arrive somewhere");
                ImGui.DragFloat("Max Queue Ahead", ref _maxQueueAhead);
                ImGui.DragFloat("Max Queue Radius", ref _maxQueueRadius);
                if (ImGui.Button("Queue"))
                {
                    AddQueue();
                }
            }

            ImGui.End();
        }
Exemplo n.º 2
0
 public PathFollowing(ISteeringBehavior pathFollowingBehavior, PathFollowingMode mode = PathFollowingMode.OneWay)
 {
     _pathFollowingBehavior = pathFollowingBehavior;
     PathFollowingMode      = mode;
 }