// Draws an array of defined functions, separated by the '%' character. Inherits offseting and scaling private static List <byte[]> Array(string[] args, long cKey, RVIVector2 offset, float scale) { List <byte[]> result = new List <byte[]>(); // Initialize server definitions if necessary if (!RVIDefinitions.Initialized) { RVIDefinitions.Initialize(); } // Parse arguments RVIVector2 position = RVIVector2.Parse(args[0]); float elementScale = float.Parse(args[1], CultureInfo.InvariantCulture); string[] fNames = args[2].Split('%'); // Apply scale RVIVector2 finalOffset = position * scale; float finalScale = elementScale * scale; // Apply offset finalOffset += offset; foreach (string func in fNames) { string[] fLines = RVIDefinitions.Definitions[func.ToUpper()]; for (int i = 0; i < fLines.Length; i++) { // Ignore comment lines, empty lines and '-' lines if ((fLines[i][0] == '#') || (fLines[i][0] == '!') || (string.IsNullOrEmpty(fLines[i]))) { continue; } else { result.AddRange(Instruction2Packet.GetBytes(fLines[i], cKey, finalOffset.x, finalOffset.y, finalScale)); } } finalOffset += new RVIVector2(elementScale, 0); } return(result); }
// Calls a definition from the dictionary in RVIDefinitions. Inherits offseting and scaling private static List <byte[]> Func(string[] args, long cKey, RVIVector2 offset, float scale) { List <byte[]> result = new List <byte[]>(); // Initialize server definitions if necessary if (!RVIDefinitions.Initialized) { RVIDefinitions.Initialize(); } // Parse args string funcName = args[0]; RVIVector2 funcOffset = RVIVector2.Parse(args[1]); float funcScale = float.Parse(args[2], CultureInfo.InvariantCulture); // Apply scale RVIVector2 finalOffset = funcOffset * scale; float finalScale = funcScale * scale; // Apply offset finalOffset += offset; // Get function program lines string[] fLines = RVIDefinitions.Definitions[funcName.ToUpper()]; for (int i = 0; i < fLines.Length; i++) { // Ignore comment lines, empty lines and '-' lines if ((fLines[i][0] == '#') || (fLines[i][0] == '!') || (string.IsNullOrEmpty(fLines[i]))) { continue; } else { // Recursively call 'GetBytes' until all instructions are atomized result.AddRange(Instruction2Packet.GetBytes(fLines[i], cKey, finalOffset.x, finalOffset.y, finalScale)); } } return(result); }
// Draws an array of 1 character-size functions. Inherits offseting and scaling private static List <byte[]> ArrayChar(string[] args, long cKey, RVIVector2 offset, float scale) { List <byte[]> result = new List <byte[]>(); // Initialize server definitions if necessary if (!RVIDefinitions.Initialized) { RVIDefinitions.Initialize(); } // Parse arguments RVIVector2 position = RVIVector2.Parse(args[0]); float elementScale = float.Parse(args[1], CultureInfo.InvariantCulture); string chars = args[2]; string[] fNames = new string[chars.Length]; for (int i = 0; i < fNames.Length; i++) { fNames[i] = chars[i].ToString(); } // Apply scale RVIVector2 finalOffset = position * scale; float finalScale = elementScale * scale; // Apply offset finalOffset += offset; foreach (string func in fNames) { if (func == "\0") { continue; } if (func == "¬") { finalOffset.y -= elementScale * 1.4f; finalOffset.x = position.x * scale; continue; } string[] fLines = RVIDefinitions.Definitions[func.ToUpper()]; List <string> lns = fLines.ToList(); foreach (string line in lns) { line.Replace("\r", "").Replace(" ", "").Replace("\t", ""); } lns.RemoveAll(o => string.IsNullOrWhiteSpace(o)); fLines = lns.ToArray(); for (int i = 0; i < fLines.Length; i++) { // Ignore comment lines, empty lines and '-' lines if ((fLines[i][0] == '#') || (fLines[i][0] == '!') || (string.IsNullOrEmpty(fLines[i]))) { continue; } else { result.AddRange(Instruction2Packet.GetBytes(fLines[i], cKey, finalOffset.x, finalOffset.y, finalScale)); } } finalOffset += new RVIVector2(elementScale, 0); } return(result); }