Exemplo n.º 1
0
        private void Join(MoveManager moveManager)
        {
            var p       = flowAreaControl.ToLocal(Mouse.GetPosition(flowAreaControl));
            var control = flowAreaControl.GetScopeByPosition(p);

            if (control == null)
            {
                return;
            }

            foreach (PositionableControl positionableControl in moveManager.Controls.Where(c => !control.Contains(c)))
            {
                var command = new AddSelectableToScopeCommand(flowAreaControl, control, positionableControl);
                commandSet.AddCommand(command);
            }
        }
Exemplo n.º 2
0
        private int Execute(CommandSet optionSet)
        {
            optionSet.showHelp = false;
            if (optionSet.help == null)
            {
                optionSet.help = new HelpCommand();
                optionSet.AddCommand(optionSet.help);
            }

            void SetHelp(string v) => optionSet.showHelp = v != null;

            if (!optionSet.Options.Contains("help"))
            {
                optionSet.Options.Add("help", "", SetHelp, hidden: true);
            }

            if (!optionSet.Options.Contains("?"))
            {
                optionSet.Options.Add("?", "", SetHelp, hidden: true);
            }

            var extra = optionSet.Options.Parse(_args);

            if (extra.Count == 0)
            {
                if (optionSet.showHelp)
                {
                    return(optionSet.help.Invoke(extra));
                }

                return(0);
            }

            var command = optionSet.GetCommand(extra);

            if (command == null)
            {
                optionSet.help.WriteUnknownCommand(extra[0]);
                return(1);
            }

            if (optionSet.showHelp)
            {
                if (command.Options == null || command.Options.Contains("help"))
                {
                    extra.Add("--help");
                    return(command.Invoke(extra));
                }

                command.Options.WriteOptionDescriptions(Console.Out);
                return(0);
            }

            return(command.Invoke(extra));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Add a command to those which can be invoked from the console.
        /// </summary>
        /// <param name="command">The string that will make the command execute</param>
        /// <param name="commandHelp">The message that will show the user how to use the command</param>
        /// <param name="info">Any information about how the command works or what it does</param>
        /// <param name="fn"></param>
        public void AddCommand(string command, string commandHelp, string infomessage, CommandDelegate fn)
        {
            CommandInfo info = new CommandInfo();

            info.command     = command;
            info.commandHelp = commandHelp;
            info.info        = infomessage;
            info.fn          = new List <CommandDelegate> ();
            info.fn.Add(fn);
            tree.AddCommand(info);
        }
Exemplo n.º 4
0
        public CommandSet <VisualizerControl.Visualizer> Initialization()
        {
            var set     = new CommandSet <VisualizerControl.Visualizer>();
            int counter = 0;

            // Add floor
            var floor    = engine.Floor;
            var floorObj = new ObjectPrototype(new Quadrilateral3D(
                                                   new Vector3D(floor.UpperLeft.X, floor.UpperLeft.Y, 0),
                                                   new Vector3D(floor.LowerLeft.X, floor.LowerLeft.Y, 0),
                                                   new Vector3D(floor.UpperRight.X, floor.UpperRight.Y, 0),
                                                   new Vector3D(floor.LowerRight.X, floor.LowerRight.Y, 0)
                                                   ), new BasicMaterial(FloorColor, .03, .5));

            set.AddCommand(new AddObject(floorObj, counter++));

            // Add walls
            foreach (var wall in engine.Walls)
            {
                var wallObj = new ObjectPrototype(new Quadrilateral3D(
                                                      new Vector3D(wall.Endpoints.Item1.X, wall.Endpoints.Item1.Y, 0),
                                                      new Vector3D(wall.Endpoints.Item2.X, wall.Endpoints.Item2.Y, 0),
                                                      new Vector3D(wall.Endpoints.Item1.X, wall.Endpoints.Item1.Y, WallHeight),
                                                      new Vector3D(wall.Endpoints.Item2.X, wall.Endpoints.Item2.Y, WallHeight)
                                                      ), new BasicMaterial(WallColor, .03, .5));
                set.AddCommand(new AddObject(wallObj, counter++));
            }

            // Add people
            foreach (var person in engine.People)
            {
                var personObj = new ObjectPrototype(new Cylinder3D(), new BasicMaterial(person.Intelligence.Color, .03, .5));
                set.AddCommand(new AddObject(personObj, counter));
                set.AddCommand(new TransformObject(counter, new Vector(person.Position.X, person.Position.Y, PersonHeight / 2),
                                                   new Vector(person.PhysicalRadius, person.PhysicalRadius, PersonHeight / 2)));
                personMap.Add(person, counter);
                ++counter;
            }

            return(set);
        }
Exemplo n.º 5
0
        public CommandSet <VisualizerControl.Visualizer> Tick(double newTime)
        {
            var set = new CommandSet <VisualizerControl.Visualizer>();

            double timeStep = newTime - engine.Time;

            Continue = engine.Tick(timeStep);

            foreach (var person in engine.People)
            {
                set.AddCommand(new MoveObject(personMap[person], person.Position.X, person.Position.Y, PersonHeight / 2));
            }

            return(set);
        }