예제 #1
0
            public string Serialize()
            {
                SRKStringBuilder builder = new SRKStringBuilder();

                builder.Append($"{name}{{");
                for (int i = 0; i < subMenues.Count; i++)
                {
                    string v = subMenues[i].Serialize();
                    builder.Append($"{{{v.Length.ToString()}}}{v}");
                }
                builder.Append($"}}{remoteCommand}");
                return(builder.ToString());
            }
        public string JoinArguments(SRKStringBuilder builder, int start, int end)
        {
            builder.Clear();
            int termination = Math.Max(ArgumentCount - 1, end);

            for (int i = start; i <= termination; ++i)
            {
                builder.Append(myCommandLine.Items[i]);
                if (i != termination)
                {
                    builder.Append(' ');
                }
            }
            return(builder.ToString());
        }
예제 #3
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (commandLine.TryParse(argument))
            {
                Action commandAction;

                string command = commandLine.Argument(0);
                if (command == null)
                {
                    Echo("No command specified");
                }
                else if (commands.TryGetValue(command, out commandAction))
                {
                    // We have found a command. Invoke it.
                    commandAction();
                }
                else
                {
                    echoBuilder.AppendLine($"Unknown command {command}");
                }
            }
            else
            {
                echoBuilder.Clear();
                echoBuilder.Append(setupBuilder.ToString());

                Action updateAction;
                if (updates.TryGetValue(currentState, out updateAction))
                {
                    updateAction();
                }

                doDisplay();
            }
        }
        public string GetStatus()
        {
            StatusBuilder.Clear();
            StatusBuilder.AppendLine($"OUTPUT MODE: {(int)OutputMode}");
            if (OutputMode == OutputMode.Profile)
            {
                profiler.StartSectionWatch("Profiler");
                profiler.PrintPerformance(StatusBuilder);
                StatusBuilder.AppendLine("============");
                profiler.PrintSectionBreakdown(StatusBuilder);
                profiler.StopSectionWatch("Profiler");
            }
            else if (OutputMode == OutputMode.Debug)
            {
                StatusBuilder.AppendLine(ExceptionBuilder.ToString());

                StatusBuilder.AppendLine("=====");

                StatusBuilder.Append("Cycle ").AppendLine(Context.Frame.ToString());
                StatusBuilder.Append(Subsystems.Count.ToString()).AppendLine("systems connected");

                foreach (KeyValuePair <string, ISubsystem> kvp in Subsystems)
                {
                    StatusBuilder.AppendLine("[" + kvp.Key + "]");
                    StatusBuilder.AppendLine(kvp.Value.GetStatus());
                }

                Context.Log.GetOutput(DebugBuilder);
                StatusBuilder.AppendLine(DebugBuilder.ToString());
                DebugBuilder.Clear();
            }
            else
            {
                return(string.Empty);
            }

            return(StatusBuilder.ToString());
        }
예제 #5
0
            public string GetStatus()
            {
                statusBuilder.Clear();

                statusBuilder.Append("CON: ");
                statusBuilder.Append(connector != null ? "AOK" : "LST");
                statusBuilder.Append(" | EXT: ");
                statusBuilder.Append(extender != null ? "AOK" : "LST");
                statusBuilder.Append(" | ROT: ");
                statusBuilder.Append(rotor != null ? "AOK" : "LST");
                statusBuilder.Append(" | GTS: ");
                statusBuilder.Append(gates.Count.ToString());

                statusBuilder.AppendLine();

                statusBuilder.AppendLine($"State: {state.ToString()}");

                statusBuilder.AppendLine($"Rotor: {rotor.Angle}");
                statusBuilder.AppendLine($"Target: {getWorldBoxTargetAngle()}");

                /*
                 * if (connector.Status == MyShipConnectorStatus.Connected)
                 * {
                 *  var dockedShipBoundingBox = connector.OtherConnector.CubeGrid.WorldAABB;
                 *  var dockedShipCenterDirection = dockedShipBoundingBox.Center - rotor.Top.WorldMatrix.Translation;
                 *  var myDir = Vector3D.TransformNormal(dockedShipCenterDirection, MatrixD.Transpose(rotor.Top.WorldMatrix));
                 *  myDir.Y = 0;
                 *  myDir.Normalize();
                 *  statusBuilder.AppendLine($"Debug: {myDir.X}");
                 *  statusBuilder.AppendLine($"Debug: {myDir.Z}");
                 *
                 *  statusBuilder.AppendLine();
                 *
                 *  var dirVector = new Vector3D(1, 0, 0);
                 *  var worldDirVector = Vector3D.TransformNormal(dirVector, connector.OtherConnector.WorldMatrix);
                 *  myDir = Vector3D.TransformNormal(worldDirVector, MatrixD.Transpose(rotor.Top.WorldMatrix));
                 *  statusBuilder.AppendLine($"Debug: {myDir.X}");
                 *  statusBuilder.AppendLine($"Debug: {myDir.Z}");
                 *  statusBuilder.AppendLine($"Target 2: {getWorldBoxTargetAngle()}");
                 * }*/

                return(statusBuilder.ToString());
            }