//TODO: Remove duplicate code private void Drow(ConsoleBlock block) { Console.ForegroundColor = block.Color; Console.SetCursorPosition(block.Position.CoordinateX, block.Position.CoordinateY); Console.WriteLine("X"); Console.ForegroundColor = defaultColor; }
//TODO: Remove duplicate code public void Drow(ConsoleBlock block, int i) { Console.ForegroundColor = block.Color; Console.SetCursorPosition(block.Position.CoordinateX, block.Position.CoordinateY); Console.WriteLine(i); Console.ForegroundColor = defaultColor; }
public static BlockJsonInfo JsonObject(Block block, float[] origin = null) { if (origin == null) { origin = origin_base; } BlockJsonInfo jsonInfo = new BlockJsonInfo { name = block.Type.ToString(), position = new float[3] { block.Position.x - origin[0], block.Position.y - origin[1], block.Position.z - origin[2] }, rotation = new float[3] { block.Rotation.x, block.Rotation.y, block.Rotation.z }, color = ColorSpaceUtility.UnquantizeToArray(block.Color), scale = new float[3] { block.Scale.x, block.Scale.y, block.Scale.z }, }; // custom stats for special blocks switch (block.Type) { case BlockIDs.TextBlock: TextBlock t = block.Specialise <TextBlock>(); jsonInfo.name += "\t" + t.Text + "\t" + t.TextBlockId; break; case BlockIDs.ConsoleBlock: ConsoleBlock c = block.Specialise <ConsoleBlock>(); jsonInfo.name += "\t" + c.Command + "\t" + c.Arg1 + "\t" + c.Arg2 + "\t" + c.Arg3; break; case BlockIDs.DampedSpring: DampedSpring d = block.Specialise <DampedSpring>(); jsonInfo.name += "\t" + d.Stiffness + "\t" + d.Damping; break; case BlockIDs.ServoAxle: case BlockIDs.ServoHinge: case BlockIDs.PneumaticAxle: case BlockIDs.PneumaticHinge: Servo s = block.Specialise <Servo>(); jsonInfo.name += "\t" + s.MinimumAngle + "\t" + s.MaximumAngle + "\t" + s.MaximumForce + "\t" + s.Reverse; break; case BlockIDs.MotorM: case BlockIDs.MotorS: Motor m = block.Specialise <Motor>(); jsonInfo.name += "\t" + m.TopSpeed + "\t" + m.Torque + "\t" + m.Reverse; break; default: break; } return(jsonInfo); }
public void PostProcess(string name, ref Block[] blocks) { // populate console block AsyncUtils.WaitForSubmission(); // just in case ConsoleBlock cb = blocks[0].Specialise <ConsoleBlock>(); cb.Command = "ChangeTextBlockCommand"; cb.Arg1 = "TextBlockID"; cb.Arg2 = commandBlockContents[name]; cb.Arg3 = ""; commandBlockContents.Remove(name); }
private static void PostProcessSpecialBlocks(ref ProcessedVoxelObjectNotation[] pVONs, ref Block[] blocks) { // populate block attributes using metadata field from ProcessedVoxelObjectNotation for (int i = 0; i < pVONs.Length; i++) { switch (pVONs[i].block) { case BlockIDs.TextBlock: string[] textSplit = pVONs[i].metadata.Split('\t'); if (textSplit.Length > 1) { TextBlock tb = blocks[i].Specialise <TextBlock>(); tb.Text = textSplit[1]; if (textSplit.Length > 2) { tb.TextBlockId = textSplit[2]; } } break; case BlockIDs.ConsoleBlock: string[] cmdSplit = pVONs[i].metadata.Split('\t'); if (cmdSplit.Length > 1) { ConsoleBlock cb = blocks[i].Specialise <ConsoleBlock>(); cb.Command = cmdSplit[1]; if (cmdSplit.Length > 2) { cb.Arg1 = cmdSplit[2]; if (cmdSplit.Length > 3) { cb.Arg1 = cmdSplit[3]; if (cmdSplit.Length > 4) { cb.Arg1 = cmdSplit[4]; } } } } break; case BlockIDs.DampedSpring: string[] springSplit = pVONs[i].metadata.Split('\t'); if (springSplit.Length > 1 && float.TryParse(springSplit[1], out float stiffness)) { DampedSpring d = blocks[i].Specialise <DampedSpring>(); d.Stiffness = stiffness; if (springSplit.Length > 2 && float.TryParse(springSplit[2], out float damping)) { d.Damping = damping; } } break; case BlockIDs.ServoAxle: case BlockIDs.ServoHinge: case BlockIDs.PneumaticAxle: case BlockIDs.PneumaticHinge: string[] servoSplit = pVONs[i].metadata.Split('\t'); if (servoSplit.Length > 1 && float.TryParse(servoSplit[1], out float minAngle)) { Servo s = blocks[i].Specialise <Servo>(); s.MinimumAngle = minAngle; if (servoSplit.Length > 2 && float.TryParse(servoSplit[2], out float maxAngle)) { s.MaximumAngle = maxAngle; if (servoSplit.Length > 3 && float.TryParse(servoSplit[3], out float maxForce)) { s.MaximumForce = maxForce; if (servoSplit.Length > 4 && bool.TryParse(servoSplit[4], out bool reverse)) { s.Reverse = reverse; } } } } break; case BlockIDs.MotorM: case BlockIDs.MotorS: string[] motorSplit = pVONs[i].metadata.Split('\t'); if (motorSplit.Length > 1 && float.TryParse(motorSplit[1], out float topSpeed)) { Motor m = blocks[i].Specialise <Motor>(); m.TopSpeed = topSpeed; if (motorSplit.Length > 2 && float.TryParse(motorSplit[2], out float torque)) { m.Torque = torque; if (motorSplit.Length > 3 && bool.TryParse(motorSplit[3], out bool reverse)) { m.Reverse = reverse; } } } break; default: break; // do nothing } } }