Exemplo n.º 1
0
        private static List <Transaction> GetListTransaction(JToken trans)
        {
            List <Transaction> listTransactions = new List <Transaction>();

            foreach (var oneTx in trans)
            {
                //For INPUTS
                List <InputRow> inputsList = new List <InputRow>();
                {
                    string  innerInputs = oneTx["inputs"].Value <JToken>().ToString();
                    JObject prevOut     = JObject.Parse(innerInputs.Trim('[', ']'));

                    var input = new InputRow
                    {
                        PrevOut = GetOutRow(JToken.Parse(prevOut["prev_out"].ToString()))
                    };
                    inputsList.Add(input);
                }

                //For Transaction
                JToken innerOuts = oneTx["out"].Value <JToken>();
                var    item      = new Transaction
                {
                    ListInputs = inputsList,                                                                              //inputs
                    TupleOuts  = new Tuple <OutRow, OutRow>(GetOutRow(innerOuts.First), GetOutRow(innerOuts.First.Next)), //outs
                    Time       = oneTx["time"].Value <long>().ConvertFromUnixTimeStamp()
                };
                listTransactions.Add(item);
            }
            return(listTransactions);
        }
Exemplo n.º 2
0
        // Retun false if not hit, retun true if hit
        public override bool CheckHit(InputRow currentInput)
        {
            InputNote inputNote = null;

            switch (trickType)
            {
            case TrickType.A:
                inputNote = currentInput.noteA;
                break;

            case TrickType.B:
                inputNote = currentInput.noteB;
                break;
            }


            // Cancel if Null
            if (inputNote == null)
            {
                return(false);
            }


            // Destroy Self if hit, just pressed
            if (inputNote.GetJustPressed())
            {
                Destroy(gameObject);
            }

            return(true);
        }
Exemplo n.º 3
0
        public string Run(string input)
        {
            Grammar grammar    = Language.Grammar;
            State   inputState = new InputRow(input).AsState();

            // Same as above without using the InputRow class:
            inputState = State.Create(grammar.InputSymbol, new[] { ValueSubstring.Create(input) });
            var result = (ValueSubstring)ProgramNode.Invoke(inputState);

            return(result?.Value);
        }
Exemplo n.º 4
0
        public ChartNode(Graph parentGraph)
        {
            var inputRow = new InputRow("Chart", "Number", this);
            var chartRow = new ChartRow();

            Rows = new List <BaseRow> {
                inputRow,
                chartRow
            };
            this.parentGraph   = parentGraph;
            tape               = chartRow.tape;
            inputRow.inputTape = tape;
        }
Exemplo n.º 5
0
        private static bool Check(string[] input1, string output1, string[] input2, string output2)
        {
            InputRow inputRow1 = new InputRow(input1);
            InputRow inputRow2 = new InputRow(input2);

            if (ExistProgram(inputRow1, output1, inputRow2, output2))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        ///     Look at the top 10 programs learned from a single example for formatting a name like in
        ///     <see cref="LearnFormatName" /> and show the behavior of them on slightly differently formatted name.
        ///     Demonstrates learning more than just the single top program, and shows the variation in outputs
        ///     among the top-ranked programs on unseen input formats.
        /// </summary>
        /// <seealso cref="LearnTop10NormalizePhoneNumber" />
        private static void LearnTop10FormatName()
        {
            var constraints = new[] { new Example(new InputRow("Greta Hermansson"), "Hermansson, G.") };
            IEnumerable <Program> programs = Learner.Instance.LearnTopK(constraints, k: 10);

            // This attempts running the top 10 programs on an input not directly similar to the example
            //  to see if any of them work anyway.
            int i = 0;

            foreach (var program in programs)
            {
                var input = new InputRow("Kettil hansson"); // Notice it's "hansson", not "Hansson".
                Console.WriteLine("Program {0}: \"{1}\" => \"{2}\"", ++i, input, program.Run(input));
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///     Look at the top 10 programs learned from a single example for extracting the last name and show
        ///     the behavior of them on slightly differently formatted name. Demonstrates learning more than just
        ///     the single top program, and shows the variation in outputs among the top-ranked programs on unseen
        ///     input formats.
        /// </summary>
        /// <seealso cref="LearnTop10NormalizePhoneNumber" />
        private static void LearnTop10ExtractName()
        {
            var constraints = new[] { new Example(new InputRow("Greta Hermansson"), "Hermansson") };
            IEnumerable <Program> programs = Learner.Instance.LearnTopK(constraints, k: 10);

            // This attempts running the top 10 programs on an input not directly similar to the example
            // to see different behaviours.
            // Here, we will see the outputs:
            // a. "Smith", corresponding to programs that extract the last name.
            // b. "Hansson Smith", corresponding to programs that extract everything after the first name.
            int i = 0;

            foreach (var program in programs)
            {
                var input = new InputRow("Kettil Hansson Smith"); // Notice that we now include a middle name too.
                Console.WriteLine("Program {0}: \"{1}\" => \"{2}\"", ++i, input, program.Run(input));
            }
        }
Exemplo n.º 8
0
        private static IEnumerable <Program> LearnAllProgram(InputRow inputRow1, string output1)
        {
            var session = new Session();

            IEnumerable <Constraint <IRow, object> > constraints = new[]
            {
                new Example(inputRow1, output1),
            };

            session.Constraints.Add(constraints);
            session.Constraints.Add(new ForbidTransformation(TransformationKind.IfThenElse));
            session.Constraints.Add(new ForbidTransformation(TransformationKind.Lookup));


            IEnumerable <Program> topKPrograms = session.LearnTopK(30);

            return(topKPrograms);
        }
Exemplo n.º 9
0
        private static Program LearnProgram(InputRow inputRow1, string output1, InputRow inputRow2, string output2)
        {
            var session = new Session();

            IEnumerable <Constraint <IRow, object> > constraints = new[]
            {
                new Example(inputRow1, output1),
                new Example(inputRow2, output2)
            };

            session.Constraints.Add(constraints);
            session.Constraints.Add(new ForbidTransformation(TransformationKind.IfThenElse));
            session.Constraints.Add(new ForbidTransformation(TransformationKind.Lookup));


            Program topRankedProgram = session.Learn();

            return(topRankedProgram);
        }
Exemplo n.º 10
0
        // Retun false if not hit, retun true if hit
        public override bool CheckHit(InputRow currentInput)
        {
            InputNote inputNote = null;

            switch (noteType)
            {
            case NoteType.LEFT:
                inputNote = currentInput.noteLeft;
                break;

            case NoteType.DOWN:
                inputNote = currentInput.noteDown;
                break;

            case NoteType.UP:
                inputNote = currentInput.noteUp;
                break;

            case NoteType.RIGHT:
                inputNote = currentInput.noteRight;
                break;
            }


            // Cancel if Null
            if (inputNote == null)
            {
                return(false);
            }


            // Destroy Self if hit, just pressed
            if (inputNote.GetJustPressed())
            {
                Destroy(gameObject);
            }

            return(true);
        }
 public void RemoveInputRow(InputRow row) {
     this.Rows.Remove(row);
 }
 public void AddInputRow(InputRow row) {
     this.Rows.Add(row);
 }
Exemplo n.º 13
0
        /// <summary>
        /// Render the right edge of the block.
        /// </summary>
        /// <param name="steps">Path of block outline.</param>
        /// <param name="highlightSteps">Path of block highlights.</param>
        /// <param name="inlineSteps">Inline block outlines.</param>
        /// <param name="highlightInlineSteps">Inline block highlights.</param>
        /// <param name="inputRows">2D array of objects, each
        /// containing position information.</param>
        /// <param name="iconWidth">Offset of first row due to icons.</param>
        /// <returns>Height of block.</returns>
        private double renderDrawRight_(JsArray <string> steps, JsArray <string> highlightSteps,
                                        JsArray <string> inlineSteps, JsArray <string> highlightInlineSteps, InputRow inputRows, double iconWidth)
        {
            double cursorX;
            var    cursorY = 0.0;
            double connectionX, connectionY;
            int    y = 0;

            foreach (InputRow row in inputRows)
            {
                cursorX = BlockSvg.SEP_SPACE_X;
                if (y == 0)
                {
                    cursorX += this.RTL ? -iconWidth : iconWidth;
                }
                highlightSteps.Push("M", (inputRows.rightEdge - 0.5) + "," +
                                    (cursorY + 0.5));
                if (this.isCollapsed())
                {
                    // Jagged right edge.
                    var input  = (Input)row[0];
                    var fieldX = cursorX;
                    var fieldY = cursorY;
                    this.renderFields_(input.fieldRow, fieldX, fieldY);
                    steps.Push(BlockSvg.JAGGED_TEETH);
                    highlightSteps.Push("h 8");
                    var remainder = row.height - BlockSvg.JAGGED_TEETH_HEIGHT;
                    steps.Push("v", remainder.ToString());
                    if (this.RTL)
                    {
                        highlightSteps.Push("v 3.9 l 7.2,3.4 m -14.5,8.9 l 7.3,3.5");
                        highlightSteps.Push("v", (remainder - 0.7).ToString());
                    }
                    this.width += BlockSvg.JAGGED_TEETH_WIDTH;
                }
                else if (row.type == BlockSvg.INLINE)
                {
                    // Inline inputs.
                    foreach (Input input in row)
                    {
                        var fieldX = cursorX;
                        var fieldY = cursorY;
                        if (row.thicker)
                        {
                            // Lower the field slightly.
                            fieldY += BlockSvg.INLINE_PADDING_Y;
                        }
                        // TODO: Align inline field rows (left/right/centre).
                        cursorX = this.renderFields_(input.fieldRow, fieldX, fieldY);
                        if (input.type != Core.DUMMY_INPUT)
                        {
                            cursorX += input.renderWidth + BlockSvg.SEP_SPACE_X;
                        }
                        if (input.type == Core.INPUT_VALUE)
                        {
                            inlineSteps.Push("M", (cursorX - BlockSvg.SEP_SPACE_X) +
                                             "," + (cursorY + BlockSvg.INLINE_PADDING_Y));
                            inlineSteps.Push("h", (BlockSvg.TAB_WIDTH - 2 -
                                                   input.renderWidth).ToString());
                            inlineSteps.Push(BlockSvg.TAB_PATH_DOWN);
                            inlineSteps.Push("v", (input.renderHeight + 1 -
                                                   BlockSvg.TAB_HEIGHT).ToString());
                            inlineSteps.Push("h", (input.renderWidth + 2 -
                                                   BlockSvg.TAB_WIDTH).ToString());
                            inlineSteps.Push("z");
                            if (this.RTL)
                            {
                                // Highlight right edge, around back of tab, and bottom.
                                highlightInlineSteps.Push("M",
                                                          (cursorX - BlockSvg.SEP_SPACE_X - 2.5 +
                                                           BlockSvg.TAB_WIDTH - input.renderWidth) + "," +
                                                          (cursorY + BlockSvg.INLINE_PADDING_Y + 0.5));
                                highlightInlineSteps.Push(
                                    BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL);
                                highlightInlineSteps.Push("v",
                                                          (input.renderHeight - BlockSvg.TAB_HEIGHT + 2.5).ToString());
                                highlightInlineSteps.Push("h",
                                                          (input.renderWidth - BlockSvg.TAB_WIDTH + 2).ToString());
                            }
                            else
                            {
                                // Highlight right edge, bottom.
                                highlightInlineSteps.Push("M",
                                                          (cursorX - BlockSvg.SEP_SPACE_X + 0.5) + "," +
                                                          (cursorY + BlockSvg.INLINE_PADDING_Y + 0.5));
                                highlightInlineSteps.Push("v", (input.renderHeight + 1).ToString());
                                highlightInlineSteps.Push("h", (BlockSvg.TAB_WIDTH - 2 -
                                                                input.renderWidth).ToString());
                                // Short highlight glint at bottom of tab.
                                highlightInlineSteps.Push("M",
                                                          (cursorX - input.renderWidth - BlockSvg.SEP_SPACE_X +
                                                           0.9) + "," + (cursorY + BlockSvg.INLINE_PADDING_Y +
                                                                         BlockSvg.TAB_HEIGHT - 0.7));
                                highlightInlineSteps.Push("l",
                                                          (BlockSvg.TAB_WIDTH * 0.46) + ",-2.1");
                            }
                            // Create inline input connection.
                            if (this.RTL)
                            {
                                connectionX = -cursorX -
                                              BlockSvg.TAB_WIDTH + BlockSvg.SEP_SPACE_X +
                                              input.renderWidth + 1;
                            }
                            else
                            {
                                connectionX = cursorX +
                                              BlockSvg.TAB_WIDTH - BlockSvg.SEP_SPACE_X -
                                              input.renderWidth - 1;
                            }
                            connectionY = cursorY + BlockSvg.INLINE_PADDING_Y + 1;
                            ((RenderedConnection)input.connection).setOffsetInBlock(connectionX, connectionY);
                        }
                    }

                    cursorX    = System.Math.Max(cursorX, inputRows.rightEdge);
                    this.width = System.Math.Max(this.width, cursorX);
                    steps.Push("H", cursorX.ToString());
                    highlightSteps.Push("H", (cursorX - 0.5).ToString());
                    steps.Push("v", row.height.ToString());
                    if (this.RTL)
                    {
                        highlightSteps.Push("v", (row.height - 1).ToString());
                    }
                }
                else if (row.type == Core.INPUT_VALUE)
                {
                    // External input.
                    var input  = (Input)row[0];
                    var fieldX = cursorX;
                    var fieldY = cursorY;
                    if (input.align != Core.ALIGN_LEFT)
                    {
                        var fieldRightX = inputRows.rightEdge - input.fieldWidth -
                                          BlockSvg.TAB_WIDTH - 2 * BlockSvg.SEP_SPACE_X;
                        if (input.align == Core.ALIGN_RIGHT)
                        {
                            fieldX += fieldRightX;
                        }
                        else if (input.align == Core.ALIGN_CENTRE)
                        {
                            fieldX += fieldRightX / 2;
                        }
                    }
                    this.renderFields_(input.fieldRow, fieldX, fieldY);
                    steps.Push(BlockSvg.TAB_PATH_DOWN);
                    var v = row.height - BlockSvg.TAB_HEIGHT;
                    steps.Push("v", v.ToString());
                    if (this.RTL)
                    {
                        // Highlight around back of tab.
                        highlightSteps.Push(BlockSvg.TAB_PATH_DOWN_HIGHLIGHT_RTL);
                        highlightSteps.Push("v", (v + 0.5).ToString());
                    }
                    else
                    {
                        // Short highlight glint at bottom of tab.
                        highlightSteps.Push("M", (inputRows.rightEdge - 5) + "," +
                                            (cursorY + BlockSvg.TAB_HEIGHT - 0.7));
                        highlightSteps.Push("l", (BlockSvg.TAB_WIDTH * 0.46) +
                                            ",-2.1");
                    }
                    // Create external input connection.
                    connectionX = this.RTL ? -inputRows.rightEdge - 1 :
                                  inputRows.rightEdge + 1;
                    ((RenderedConnection)input.connection).setOffsetInBlock(connectionX, cursorY);
                    if (input.connection.isConnected())
                    {
                        this.width = System.Math.Max(this.width, inputRows.rightEdge +
                                                     ((BlockSvg)input.connection.targetBlock()).getHeightWidth().width -
                                                     BlockSvg.TAB_WIDTH + 1);
                    }
                }
                else if (row.type == Core.DUMMY_INPUT)
                {
                    // External naked field.
                    var input  = (Input)row[0];
                    var fieldX = cursorX;
                    var fieldY = cursorY;
                    if (input.align != Core.ALIGN_LEFT)
                    {
                        var fieldRightX = inputRows.rightEdge - input.fieldWidth -
                                          2 * BlockSvg.SEP_SPACE_X;
                        if (inputRows.hasValue)
                        {
                            fieldRightX -= BlockSvg.TAB_WIDTH;
                        }
                        if (input.align == Core.ALIGN_RIGHT)
                        {
                            fieldX += fieldRightX;
                        }
                        else if (input.align == Core.ALIGN_CENTRE)
                        {
                            fieldX += fieldRightX / 2;
                        }
                    }
                    this.renderFields_(input.fieldRow, fieldX, fieldY);
                    steps.Push("v", row.height.ToString());
                    if (this.RTL)
                    {
                        highlightSteps.Push("v", (row.height - 1).ToString());
                    }
                }
                else if (row.type == Core.NEXT_STATEMENT)
                {
                    // Nested statement.
                    var input = (Input)row[0];
                    if (y == 0)
                    {
                        // If the first input is a statement stack, add a small row on top.
                        steps.Push("v", BlockSvg.SEP_SPACE_Y.ToString());
                        if (this.RTL)
                        {
                            highlightSteps.Push("v", (BlockSvg.SEP_SPACE_Y - 1).ToString());
                        }
                        cursorY += BlockSvg.SEP_SPACE_Y;
                    }
                    var fieldX = cursorX;
                    var fieldY = cursorY;
                    if (input.align != Core.ALIGN_LEFT)
                    {
                        var fieldRightX = inputRows.statementEdge - input.fieldWidth -
                                          2 * BlockSvg.SEP_SPACE_X;
                        if (input.align == Core.ALIGN_RIGHT)
                        {
                            fieldX += fieldRightX;
                        }
                        else if (input.align == Core.ALIGN_CENTRE)
                        {
                            fieldX += fieldRightX / 2;
                        }
                    }
                    this.renderFields_(input.fieldRow, fieldX, fieldY);
                    cursorX = inputRows.statementEdge + BlockSvg.NOTCH_WIDTH;
                    steps.Push("H", cursorX.ToString());
                    steps.Push(BlockSvg.INNER_TOP_LEFT_CORNER);
                    steps.Push("v", (row.height - 2 * BlockSvg.CORNER_RADIUS).ToString());
                    steps.Push(BlockSvg.INNER_BOTTOM_LEFT_CORNER);
                    steps.Push("H", inputRows.rightEdge.ToString());
                    if (this.RTL)
                    {
                        highlightSteps.Push("M",
                                            (cursorX - BlockSvg.NOTCH_WIDTH +
                                             BlockSvg.DISTANCE_45_OUTSIDE) +
                                            "," + (cursorY + BlockSvg.DISTANCE_45_OUTSIDE));
                        highlightSteps.Push(
                            BlockSvg.INNER_TOP_LEFT_CORNER_HIGHLIGHT_RTL);
                        highlightSteps.Push("v",
                                            (row.height - 2 * BlockSvg.CORNER_RADIUS).ToString());
                        highlightSteps.Push(
                            BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_RTL);
                        highlightSteps.Push("H", (inputRows.rightEdge - 0.5).ToString());
                    }
                    else
                    {
                        highlightSteps.Push("M",
                                            (cursorX - BlockSvg.NOTCH_WIDTH +
                                             BlockSvg.DISTANCE_45_OUTSIDE) + "," +
                                            (cursorY + row.height - BlockSvg.DISTANCE_45_OUTSIDE));
                        highlightSteps.Push(
                            BlockSvg.INNER_BOTTOM_LEFT_CORNER_HIGHLIGHT_LTR);
                        highlightSteps.Push("H", (inputRows.rightEdge - 0.5).ToString());
                    }
                    // Create statement connection.
                    connectionX = this.RTL ? -cursorX : cursorX + 1;
                    ((RenderedConnection)input.connection).setOffsetInBlock(connectionX, cursorY + 1);

                    if (input.connection.isConnected())
                    {
                        this.width = System.Math.Max(this.width, inputRows.statementEdge +
                                                     ((BlockSvg)input.connection.targetBlock()).getHeightWidth().width);
                    }
                    if (y == inputRows.Length - 1 ||
                        ((InputRow)inputRows[y + 1]).type == Core.NEXT_STATEMENT)
                    {
                        // If the final input is a statement stack, add a small row underneath.
                        // Consecutive statement stacks are also separated by a small divider.
                        steps.Push("v", BlockSvg.SEP_SPACE_Y.ToString());
                        if (this.RTL)
                        {
                            highlightSteps.Push("v", (BlockSvg.SEP_SPACE_Y - 1).ToString());
                        }
                        cursorY += BlockSvg.SEP_SPACE_Y;
                    }
                }
                cursorY += row.height;
                y++;
            }
            if (inputRows.Length == 0)
            {
                cursorY = BlockSvg.MIN_BLOCK_Y;
                steps.Push("V", cursorY.ToString());
                if (this.RTL)
                {
                    highlightSteps.Push("V", (cursorY - 1).ToString());
                }
            }
            return(cursorY);
        }
Exemplo n.º 14
0
        /// <summary>
        /// Draw the path of the block.
        /// Move the fields to the correct locations.
        /// </summary>
        /// <param name="iconWidth">Offset of first row due to icons.</param>
        /// <param name="inputRows">2D array of objects, each
        /// containing position information.</param>
        private void renderDraw_(double iconWidth, InputRow inputRows)
        {
            this.startHat_ = false;
            // Reset the height to zero and let the rendering process add in
            // portions of the block height as it goes. (e.g. hats, inputs, etc.)
            this.height = 0;
            // Should the top and bottom left corners be rounded or square?
            if (this.outputConnection != null)
            {
                this.squareTopLeftCorner_    = true;
                this.squareBottomLeftCorner_ = true;
            }
            else
            {
                this.squareTopLeftCorner_    = false;
                this.squareBottomLeftCorner_ = false;
                // If this block is in the middle of a stack, square the corners.
                if (this.previousConnection != null)
                {
                    var prevBlock = this.previousConnection.targetBlock();
                    if (prevBlock != null && prevBlock.getNextBlock() == this)
                    {
                        this.squareTopLeftCorner_ = true;
                    }
                }
                else if (BlockSvg.START_HAT)
                {
                    // No output or previous connection.
                    this.squareTopLeftCorner_ = true;
                    this.startHat_            = true;
                    this.height        += BlockSvg.START_HAT_HEIGHT;
                    inputRows.rightEdge = System.Math.Max(inputRows.rightEdge, 100);
                }
                var nextBlock = this.getNextBlock();
                if (nextBlock != null)
                {
                    this.squareBottomLeftCorner_ = true;
                }
            }

            // Assemble the block's path.
            var steps       = new JsArray <string>();
            var inlineSteps = new JsArray <string>();
            // The highlighting applies to edges facing the upper-left corner.
            // Since highlighting is a two-pixel wide border, it would normally overhang
            // the edge of the block by a pixel. So undersize all measurements by a pixel.
            var highlightSteps       = new JsArray <string>();
            var highlightInlineSteps = new JsArray <string>();

            this.renderDrawTop_(steps, highlightSteps, inputRows.rightEdge);
            var cursorY = this.renderDrawRight_(steps, highlightSteps, inlineSteps,
                                                highlightInlineSteps, inputRows, iconWidth);

            this.renderDrawBottom_(steps, highlightSteps, cursorY);
            this.renderDrawLeft_(steps, highlightSteps);

            var pathString = steps.Join(" ") + "\n" + inlineSteps.Join(" ");

            this.svgPath_.SetAttribute("d", pathString);
            this.svgPathDark_.SetAttribute("d", pathString);
            pathString = highlightSteps.Join(" ") + "\n" + highlightInlineSteps.Join(" ");
            this.svgPathLight_.SetAttribute("d", pathString);
            if (this.RTL)
            {
                // Mirror the block's path.
                this.svgPath_.SetAttribute("transform", "scale(-1 1)");
                this.svgPathLight_.SetAttribute("transform", "scale(-1 1)");
                this.svgPathDark_.SetAttribute("transform", "translate(1,1) scale(-1 1)");
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Computes the height and widths for each row and field.
        /// </summary>
        /// <param name="iconWidth">Offset of first row due to icons.</param>
        /// <returns>2D array of objects, each containing
        /// position information.</returns>
        private InputRow renderCompute_(double iconWidth)
        {
            var inputList = this.inputList;
            var inputRows = new InputRow();

            inputRows.rightEdge = iconWidth + BlockSvg.SEP_SPACE_X * 2;
            if (this.previousConnection != null || this.nextConnection != null)
            {
                inputRows.rightEdge = System.Math.Max(inputRows.rightEdge,
                                                      BlockSvg.NOTCH_WIDTH + BlockSvg.SEP_SPACE_X);
            }
            var fieldValueWidth     = 0.0;          // Width of longest external value field.
            var fieldStatementWidth = 0.0;          // Width of longest statement field.
            var hasValue            = false;
            var hasStatement        = false;
            var hasDummy            = false;
            int?lastType            = null;
            var isInline            = this.getInputsInline() && !this.isCollapsed();
            int i = 0;

            foreach (var input in inputList)
            {
                InputRow row;
                if (!input.isVisible())
                {
                    i++;
                    continue;
                }
                if (!isInline || !lastType.HasValue ||
                    lastType == Core.NEXT_STATEMENT ||
                    input.type == Core.NEXT_STATEMENT)
                {
                    // Create new row.
                    lastType = input.type;
                    row      = new InputRow();
                    if (isInline && input.type != Core.NEXT_STATEMENT)
                    {
                        row.type = BlockSvg.INLINE;
                    }
                    else
                    {
                        row.type = input.type;
                    }
                    row.height = 0.0;
                    inputRows.Push(row);
                }
                else
                {
                    row = (InputRow)inputRows[inputRows.Length - 1];
                }
                row.Push(input);

                // Compute minimum input size.
                input.renderHeight = BlockSvg.MIN_BLOCK_Y;
                // The width is currently only needed for inline value inputs.
                if (isInline && input.type == Core.INPUT_VALUE)
                {
                    input.renderWidth = BlockSvg.TAB_WIDTH +
                                        BlockSvg.SEP_SPACE_X * 1.25;
                }
                else
                {
                    input.renderWidth = 0;
                }
                // Expand input size if there is a connection.
                if (input.connection != null && input.connection.isConnected())
                {
                    var linkedBlock = (BlockSvg)input.connection.targetBlock();
                    var bBox        = linkedBlock.getHeightWidth();
                    input.renderHeight = System.Math.Max(input.renderHeight, bBox.height);
                    input.renderWidth  = System.Math.Max(input.renderWidth, bBox.width);
                }
                // Blocks have a one pixel shadow that should sometimes overhang.
                if (!isInline && i == inputList.Length - 1)
                {
                    // Last value input should overhang.
                    input.renderHeight--;
                }
                else if (!isInline && input.type == Core.INPUT_VALUE &&
                         inputList[i + 1] != null && inputList[i + 1].type == Core.NEXT_STATEMENT)
                {
                    // Value input above statement input should overhang.
                    input.renderHeight--;
                }

                row.height       = System.Math.Max(row.height, input.renderHeight);
                input.fieldWidth = 0;
                if (inputRows.Length == 1)
                {
                    // The first row gets shifted to accommodate any icons.
                    input.fieldWidth += this.RTL ? -iconWidth : iconWidth;
                }
                var previousFieldEditable = false;
                int j = 0;
                foreach (var field in input.fieldRow)
                {
                    if (j != 0)
                    {
                        input.fieldWidth += BlockSvg.SEP_SPACE_X;
                    }
                    // Get the dimensions of the field.
                    var fieldSize = field.getSize();
                    field.renderWidth = fieldSize.width;
                    field.renderSep   = (previousFieldEditable && field.EDITABLE) ?
                                        BlockSvg.SEP_SPACE_X : 0;
                    input.fieldWidth     += field.renderWidth + field.renderSep;
                    row.height            = System.Math.Max(row.height, fieldSize.height);
                    previousFieldEditable = field.EDITABLE;
                    j++;
                }

                if (row.type != BlockSvg.INLINE)
                {
                    if (row.type == Core.NEXT_STATEMENT)
                    {
                        hasStatement        = true;
                        fieldStatementWidth = System.Math.Max(fieldStatementWidth, input.fieldWidth);
                    }
                    else
                    {
                        if (row.type == Core.INPUT_VALUE)
                        {
                            hasValue = true;
                        }
                        else if (row.type == Core.DUMMY_INPUT)
                        {
                            hasDummy = true;
                        }
                        fieldValueWidth = System.Math.Max(fieldValueWidth, input.fieldWidth);
                    }
                }
                i++;
            }

            // Make inline rows a bit thicker in order to enclose the values.
            foreach (InputRow row in inputRows)
            {
                row.thicker = false;
                if (row.type == BlockSvg.INLINE)
                {
                    foreach (Input input in row)
                    {
                        if (input.type == Core.INPUT_VALUE)
                        {
                            row.height += 2 * BlockSvg.INLINE_PADDING_Y;
                            row.thicker = true;
                            break;
                        }
                    }
                }
            }

            // Compute the statement edge.
            // This is the width of a block where statements are nested.
            inputRows.statementEdge = 2 * BlockSvg.SEP_SPACE_X +
                                      fieldStatementWidth;
            // Compute the preferred right edge.  Inline blocks may extend beyond.
            // This is the width of the block where external inputs connect.
            if (hasStatement)
            {
                inputRows.rightEdge = System.Math.Max(inputRows.rightEdge,
                                                      inputRows.statementEdge + BlockSvg.NOTCH_WIDTH);
            }
            if (hasValue)
            {
                inputRows.rightEdge = System.Math.Max(inputRows.rightEdge, fieldValueWidth +
                                                      BlockSvg.SEP_SPACE_X * 2 + BlockSvg.TAB_WIDTH);
            }
            else if (hasDummy)
            {
                inputRows.rightEdge = System.Math.Max(inputRows.rightEdge, fieldValueWidth +
                                                      BlockSvg.SEP_SPACE_X * 2);
            }

            inputRows.hasValue     = hasValue;
            inputRows.hasStatement = hasStatement;
            inputRows.hasDummy     = hasDummy;
            return(inputRows);
        }
Exemplo n.º 16
0
    private void Populate()
    {
        Character currentCharacter = SelectedCharacter();

        if (currentCharacter == null)
        {
            WindowTitle.text = "No Character Selected";
            return;
        }
        if (edit)
        {
            WindowTitle.text = "Edit " + currentCharacter.Name;
        }
        else
        {
            WindowTitle.text = "View " + currentCharacter.Name;
        }
        Name.text       = currentCharacter.Name;
        MaxHP.text      = currentCharacter.MaxHP.ToString();
        Speed.text      = currentCharacter.Speed.ToString();
        Experience.text = currentCharacter.Experience.ToString();

        if (!edit)
        {
            Name.interactable       = false;
            MaxHP.interactable      = false;
            Speed.interactable      = false;
            Experience.interactable = false;
            Abilities.interactable  = false;
            Skills.interactable     = false;
            Modifiers.interactable  = false;
        }
        else
        {
            Name.interactable       = true;
            MaxHP.interactable      = true;
            Speed.interactable      = true;
            Experience.interactable = true;
            Abilities.interactable  = true;
            Skills.interactable     = true;
            Modifiers.interactable  = true;
        }

        if (Abilities == null)
        {
            return;
        }
        string[] abilities = currentCharacter.GetAbilities();
        foreach (string ability in abilities)
        {
            InputRow instance = Abilities.AddRow();
            instance.RowElements[0].GetComponent <Text>().text       = ability;
            instance.RowElements[1].GetComponent <InputField>().text =
                currentCharacter.GetAbilityBase(ability).ToString();
            instance.RowElements[2].GetComponent <Toggle>().isOn =
                currentCharacter.HasProficiency(ability);
            if (!edit)
            {
                instance.RowElements[1].GetComponent <InputField>().interactable = false;
                instance.RowElements[2].GetComponent <Toggle>().interactable     = false;
                instance.interactable = false;
            }
        }

        if (Skills == null)
        {
            return;
        }
        string[] skills = currentCharacter.GetSkills();
        foreach (string skill in skills)
        {
            InputRow instance = Skills.AddRow();
            instance.RowElements[0].GetComponent <Text>().text       = skill;
            instance.RowElements[1].GetComponent <InputField>().text =
                currentCharacter.GetSkillType(skill);
            instance.RowElements[2].GetComponent <Toggle>().isOn =
                currentCharacter.HasProficiency(skill);
            if (!edit)
            {
                instance.RowElements[1].GetComponent <InputField>().interactable = false;
                instance.RowElements[2].GetComponent <Toggle>().interactable     = false;
                instance.interactable = false;
            }
        }

        if (Modifiers == null)
        {
            return;
        }
        string[] modifierTypes = currentCharacter.Modifiers.GetTypes();
        foreach (string type in modifierTypes)
        {
            foreach (Modifier mod in currentCharacter.Modifiers.Get(type))
            {
                InputRow instance = Modifiers.AddRow();
                instance.RowElements[0].GetComponent <InputField>().SetTextWithoutNotify(mod.Name);
                instance.RowElements[1].GetComponent <InputField>().SetTextWithoutNotify(mod.Type);
                instance.RowElements[2].GetComponent <Toggle>().isOn = mod.Active;
                instance.RowElements[3].GetComponent <InputField>().SetTextWithoutNotify(mod.Expr);
                instance.RowElements[4].GetComponent <InputField>().SetTextWithoutNotify(mod.Condition);
                if (!edit)
                {
                    instance.RowElements[0].GetComponent <InputField>().interactable = false;
                    instance.RowElements[1].GetComponent <InputField>().interactable = false;
                    instance.RowElements[2].GetComponent <Toggle>().interactable     = false;
                    instance.RowElements[3].GetComponent <InputField>().interactable = false;
                    instance.RowElements[4].GetComponent <InputField>().interactable = false;
                    instance.interactable = false;
                }
            }
        }
    }
Exemplo n.º 17
0
        void ConnectToInput()
        {
            MInput input = GetComponent <MInput>();

            if (input == null)
            {
                input = gameObject.AddComponent <MInput>();
            }

            BoolVar RiderCombatMode = MalbersTools.GetInstance <BoolVar>("RC Combat Mode");

            BoolVar RCWeaponInput = MalbersTools.GetInstance <BoolVar>("RC Weapon Input");
            var     inv           = GetComponent <MInventory>();

            #region AIM INPUT

            var AIM = input.FindInput("Aim");
            if (AIM == null)
            {
                AIM = new InputRow("Aim", "Aim", KeyCode.Mouse1, InputButton.Press, InputType.Key);
                input.inputs.Add(AIM);

                AIM.active.Variable    = RiderCombatMode;
                AIM.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(AIM.OnInputChanged, SetAim);

                Debug.Log("<B>Aim</B> Input created and connected to RiderCombat.SetAim()");
            }
            #endregion

            #region RiderAttack1 INPUT
            var RCA1 = input.FindInput("RiderAttack1");
            if (RCA1 == null)
            {
                RCA1 = new InputRow("RiderAttack1", "RiderAttack1", KeyCode.Mouse0, InputButton.Press, InputType.Key);
                input.inputs.Add(RCA1);

                RCA1.active.Variable    = RiderCombatMode;
                RCA1.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA1.OnInputDown, MainAttack);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA1.OnInputUp, MainAttackReleased);

                Debug.Log("<B>RiderAttack1</B> Input created and connected to RiderCombat.MainAttack() and RiderCombat.MainAttackReleased() ");
            }
            #endregion

            #region RiderAttack2 INPUT
            var RCA2 = input.FindInput("RiderAttack2");
            if (RCA2 == null)
            {
                RCA2 = new InputRow("RiderAttack2", "RiderAttack2", KeyCode.Mouse1, InputButton.Press, InputType.Key);
                input.inputs.Add(RCA2);

                RCA2.active.Variable    = RiderCombatMode;
                RCA2.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA2.OnInputDown, SecondAttack);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA2.OnInputUp, SecondAttackReleased);

                Debug.Log("<B>RiderAttack2</B> Input created and connected to RiderCombat.SecondAttack() and RiderCombat.SecondAttackReleased() ");
            }
            #endregion

            #region Reload INPUT
            var Reload = input.FindInput("Reload");
            if (Reload == null)
            {
                Reload = new InputRow("Reload", "Reload", KeyCode.R, InputButton.Down, InputType.Key);
                input.inputs.Add(Reload);

                Reload.active.Variable    = RiderCombatMode;
                Reload.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(Reload.OnInputDown, ReloadWeapon);

                Debug.Log("<B>Reload</B> Input created and connected to RiderCombat.ReloadWeapon() ");
            }
            #endregion

            #region Weapon1 INPUT
            var w1 = input.FindInput("Weapon1");
            if (w1 == null)
            {
                w1 = new InputRow("Weapon1", "Weapon1", KeyCode.Alpha4, InputButton.Down, InputType.Key);
                input.inputs.Add(w1);

                w1.active.Variable    = RCWeaponInput;
                w1.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(w1.OnInputDown, Change_Weapon_Holder_Back);

                if (inv)
                {
                    UnityEditor.Events.UnityEventTools.AddIntPersistentListener(w1.OnInputDown, inv.EquipItem, 0);
                }

                Debug.Log("<B>Weapon1</B> Input created and connected to RiderCombat.Change_Weapon_Holder_Back() ");
            }
            #endregion

            #region Weapon2 INPUT
            var w2 = input.FindInput("Weapon2");
            if (w2 == null)
            {
                w2 = new InputRow("Weapon2", "Weapon2", KeyCode.Alpha5, InputButton.Down, InputType.Key);
                input.inputs.Add(w2);

                w2.active.Variable    = RCWeaponInput;
                w2.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(w2.OnInputDown, Change_Weapon_Holder_Left);

                if (inv)
                {
                    UnityEditor.Events.UnityEventTools.AddIntPersistentListener(w2.OnInputDown, inv.EquipItem, 1);
                }

                Debug.Log("<B>Weapon2</B> Input created and connected to RiderCombat.Change_Weapon_Holder_Left() ");
            }
            #endregion

            #region Weapon3 INPUT
            var w3 = input.FindInput("Weapon3");
            if (w3 == null)
            {
                w3 = new InputRow("Weapon3", "Weapon3", KeyCode.Alpha6, InputButton.Down, InputType.Key);
                input.inputs.Add(w3);

                w3.active.Variable    = RCWeaponInput;
                w3.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(w3.OnInputDown, Change_Weapon_Holder_Right);

                if (inv)
                {
                    UnityEditor.Events.UnityEventTools.AddIntPersistentListener(w3.OnInputDown, inv.EquipItem, 2);
                }

                Debug.Log("<B>Weapon3</B> Input created and connected to RiderCombat.Change_Weapon_Holder_Right() ");
            }
            #endregion
        }
Exemplo n.º 18
0
        void ConnectToInput()
        {
            MInput input = GetComponent <MInput>();

            if (input == null)
            {
                input = gameObject.AddComponent <MInput>();
            }


            #region Mount Input
            var mountInput = input.FindInput("Mount");

            if (mountInput == null)
            {
                mountInput = new InputRow("Mount", "Mount", KeyCode.F, InputButton.Down, InputType.Key);
                input.inputs.Add(mountInput);

                mountInput.active.Variable    = MalbersTools.GetInstance <BoolVar>("Can Mount");
                mountInput.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(mountInput.OnInputDown, MountAnimal);


                Debug.Log("<B>Mount</B> Input created and connected to Rider.MountAnimal");
            }
            #endregion

            #region Dismount Input


            var DismountInput = input.FindInput("Dismount");

            if (DismountInput == null)
            {
                DismountInput = new InputRow("Dismount", "Dismount", KeyCode.F, InputButton.LongPress, InputType.Key);

                DismountInput.LongPressTime = 0.2f;

                input.inputs.Add(DismountInput);

                DismountInput.active.Variable    = MalbersTools.GetInstance <BoolVar>("Can Dismount");
                DismountInput.active.UseConstant = false;

                var RiderDismountUI = MalbersTools.GetInstance <MEvent>("Rider Dismount UI");

                UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnLongPress, DismountAnimal);

                if (RiderDismountUI != null)
                {
                    UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnLongPress, RiderDismountUI.Invoke);
                    UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnPressedNormalized, RiderDismountUI.Invoke);
                    UnityEditor.Events.UnityEventTools.AddPersistentListener(DismountInput.OnInputUp, RiderDismountUI.Invoke);
                    UnityEditor.Events.UnityEventTools.AddIntPersistentListener(DismountInput.OnInputDown, RiderDismountUI.Invoke, 0);
                }


                Debug.Log("<B>Dismount</B> Input created and connected to Rider.DismountAnimal");
            }

            #endregion

            #region CanCallMount Input


            var CanCallMount = input.FindInput("Call Mount");

            if (CanCallMount == null)
            {
                CanCallMount = new InputRow("Call Mount", "Call Mount", KeyCode.F, InputButton.Down, InputType.Key);
                input.inputs.Add(CanCallMount);

                CanCallMount.active.Variable    = MalbersTools.GetInstance <BoolVar>("Can Call Mount");
                CanCallMount.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(CanCallMount.OnInputDown, CallAnimalToggle);


                Debug.Log("<B>Call Mount</B> Input created and connected to Rider.CallAnimalToggle");
            }

            #endregion
        }
Exemplo n.º 19
0
 // Retun false if not hit, retun true if hit
 public virtual bool CheckHit(InputRow currentInput)
 {
     return(false);
 }
Exemplo n.º 20
0
        private static void ConstructColor(string indir, string outdir, string filename, int index)
        {
            string path = indir + filename + ".txt";

            string[] readText = File.ReadAllLines(path);
            int      n = readText.Length;
            int      i, j, k;

            Console.WriteLine(n.ToString() + " examples read.");
            if (n > 100)
            {
                return;
            }
            HashSet <HashSet <int> > allPrograms = new HashSet <HashSet <int> >();

            using (StreamWriter file = new StreamWriter(outdir + filename + "_newcolor.txt"))
            {
                file.WriteLine(n);
                int total = n;
                int cnt   = 0;
                for (i = 0; i < n; i++)
                {
                    cnt++;
                    Console.WriteLine(filename + " " + cnt.ToString() + "/" + total.ToString());
                    try
                    {
                        string ex1 = readText[i];

                        string[] debris1 = ex1.Split('^');

                        if (debris1.Length == 2)
                        {
                            string[] input1 = debris1[0].Split('|');

                            InputRow in1 = new InputRow(input1);

                            string output1 = debris1[1];

                            IEnumerable <Program> topKPrograms = LearnAllProgram(in1, output1);

                            foreach (Program p in topKPrograms)
                            {
                                if (p != null)
                                {
                                    HashSet <int> prog = new HashSet <int>();
                                    for (k = 0; k < n; k++)
                                    {
                                        string   test       = readText[k];
                                        string[] debrisTest = test.Split('^');

                                        string[] goin = debrisTest[0].Split('|');
                                        InputRow go   = new InputRow(goin);
                                        string   outs = debrisTest[1];
                                        string   ret  = p.Run(go) as string;
                                        if (ret == outs)
                                        {
                                            //Console.WriteLine(i.ToString() + " " + j.ToString() + " " + k.ToString());
                                            prog.Add(k);
                                        }
                                    }
                                    bool take = true;
                                    allPrograms.RemoveWhere(s => s.IsSubsetOf(prog));
                                    foreach (HashSet <int> pp in allPrograms)
                                    {
                                        if (prog.IsSubsetOf(pp))
                                        {
                                            take = false;
                                            break;
                                        }
                                    }
                                    if (take)
                                    {
                                        allPrograms.Add(prog);
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Exception caught.");
                        Console.WriteLine(e);
                    }
                }
                int color = 0;
                foreach (HashSet <int> prog in allPrograms)
                {
                    Console.WriteLine("=====");
                    foreach (var v in prog)
                    {
                        foreach (var u in prog)
                        {
                            if (v < u)
                            {
                                file.WriteLine(v.ToString() + " " + u.ToString() + " " + color.ToString());
                                //Console.WriteLine(v.ToString() + " " + u.ToString() + " " + color.ToString());
                            }
                        }
                    }
                    color += 1;
                }
            }
        }
 public InputRowChangeEvent(InputRow row, global::System.Data.DataRowAction action) {
     this.eventRow = row;
     this.eventAction = action;
 }
Exemplo n.º 22
0
        protected void CreateInputs()
        {
#if UNITY_EDITOR
            MInput input = GetComponent <MInput>();

            if (input == null)
            {
                input = gameObject.AddComponent <MInput>();
            }

            #region Open Close Input
            var OpenCloseInput = input.FindInput("OpenSelector");
            if (OpenCloseInput == null)
            {
                OpenCloseInput = new InputRow("OpenSelector", "OpenSelector", KeyCode.Escape, InputButton.Down, InputType.Key);
                input.inputs.Add(OpenCloseInput);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(OpenCloseInput.OnInputDown, ToggleSelector);
            }
            #endregion

            #region Submit Input
            var Submit = input.FindInput("Submit");
            if (Submit == null)
            {
                Submit = new InputRow("Submit", "Submit", KeyCode.Return, InputButton.Down, InputType.Key);
                input.inputs.Add(Submit);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(Submit.OnInputDown, Controller.Submit_Input);
            }
            #endregion

            #region ChangeLeft Input
            var ChangeLeft = input.FindInput("ChangeLeft");
            if (ChangeLeft == null)
            {
                ChangeLeft = new InputRow("ChangeLeft", "ChangeLeft", KeyCode.LeftArrow, InputButton.Down, InputType.Key);
                input.inputs.Add(ChangeLeft);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(ChangeLeft.OnInputDown, Controller.ChangeLeft);
            }
            #endregion

            #region ChangeRight Input
            var ChangeRight = input.FindInput("ChangeRight");
            if (ChangeRight == null)
            {
                ChangeRight = new InputRow("ChangeRight", "ChangeRight", KeyCode.RightArrow, InputButton.Down, InputType.Key);
                input.inputs.Add(ChangeRight);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(ChangeRight.OnInputDown, Controller.ChangeRight);
            }
            #endregion

            #region ChangeUp Input
            var ChangeUp = input.FindInput("ChangeUp");
            if (ChangeUp == null)
            {
                ChangeUp = new InputRow("ChangeUp", "ChangeUp", KeyCode.UpArrow, InputButton.Down, InputType.Key);
                input.inputs.Add(ChangeUp);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(ChangeUp.OnInputDown, Controller.ChangeUp);
            }
            #endregion

            #region ChangeDown Input
            var ChangeDown = input.FindInput("ChangeDown");
            if (ChangeDown == null)
            {
                ChangeDown = new InputRow("ChangeDown", "ChangeDown", KeyCode.DownArrow, InputButton.Down, InputType.Key);
                input.inputs.Add(ChangeDown);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(ChangeDown.OnInputDown, Controller.ChangeDown);
            }
            #endregion

            UnityEditor.EditorUtility.SetDirty(this);
            UnityEditor.EditorUtility.SetDirty(input);
#endif
        }
Exemplo n.º 23
0
 // This is the custom mapping. We now separate it into a method, so that we can use it both in training and in loading.
 public static void IncomeMapping(InputRow input, OutputRow output) => output.Label = input.Income > 50000;
Exemplo n.º 24
0
        void ConnectToInput()
        {
            MInput input = GetComponent <MInput>();

            if (input == null)
            {
                input = gameObject.AddComponent <MInput>();
            }

            BoolVar RiderCombatMode = MTools.GetInstance <BoolVar>("RC Combat Mode");

            BoolVar RCWeaponInput = MTools.GetInstance <BoolVar>("RC Weapon Input");


            #region AIM INPUT

            var AIM = input.FindInput("Aim");
            if (AIM == null)
            {
                AIM = new InputRow("Aim", "Aim", KeyCode.Mouse1, InputButton.Press, InputType.Key);
                input.inputs.Add(AIM);

                AIM.active.Variable    = RiderCombatMode;
                AIM.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(AIM.OnInputChanged, Aim_Set);
                Debug.Log("<B>Aim</B> Input created and connected to RiderCombat.SetAim()");
            }
            #endregion

            #region RiderAttack1 INPUT
            var RCA1 = input.FindInput("RiderAttack1");
            if (RCA1 == null)
            {
                RCA1 = new InputRow("RiderAttack1", "RiderAttack1", KeyCode.Mouse0, InputButton.Press, InputType.Key);
                input.inputs.Add(RCA1);

                RCA1.active.Variable    = RiderCombatMode;
                RCA1.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA1.OnInputDown, MainAttack);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA1.OnInputUp, MainAttackReleased);

                Debug.Log("<B>RiderAttack1</B> Input created and connected to RiderCombat.MainAttack() and RiderCombat.MainAttackReleased()");
            }
            #endregion

            #region RiderAttack2 INPUT
            var RCA2 = input.FindInput("RiderAttack2");
            if (RCA2 == null)
            {
                RCA2 = new InputRow("RiderAttack2", "RiderAttack2", KeyCode.Mouse1, InputButton.Press, InputType.Key);
                input.inputs.Add(RCA2);

                RCA2.active.Variable    = RiderCombatMode;
                RCA2.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA2.OnInputDown, SecondAttack);
                UnityEditor.Events.UnityEventTools.AddPersistentListener(RCA2.OnInputUp, SecondAttackReleased);

                Debug.Log("<B>RiderAttack2</B> Input created and connected to RiderCombat.SecondAttack() and RiderCombat.SecondAttackReleased() ");
            }
            #endregion

            #region Reload INPUT
            var Reload = input.FindInput("Reload");
            if (Reload == null)
            {
                Reload = new InputRow("Reload", "Reload", KeyCode.R, InputButton.Down, InputType.Key);
                input.inputs.Add(Reload);

                Reload.active.Variable    = RiderCombatMode;
                Reload.active.UseConstant = false;

                UnityEditor.Events.UnityEventTools.AddPersistentListener(Reload.OnInputDown, ReloadWeapon);

                Debug.Log("<B>Reload</B> Input created and connected to RiderCombat.ReloadWeapon() ");
            }
            #endregion

            EditorUtility.SetDirty(input);
        }