public static SimGroup MovingPlatform(string from, string to, string Rot, string Scale, string interior, int index, string name, bool doesReturn = true, string time = "5000", string smoothing = "Linear") { var platform = new PathedInterior(interior, index, Vector.Zero, new AngAxis(Rot), new Vector(Scale)) { objname = name + "MP" }; var fromMarker = new Marker(time, "0", smoothing, new Vector(from), AngAxis.Identity, Vector.One); var toMarker = new Marker(time, "1", smoothing, new Vector(to), AngAxis.Identity, Vector.One); Marker returnMarker = null; if (doesReturn) { returnMarker = new Marker(time, "2", smoothing, new Vector(from), AngAxis.Identity, Vector.One); } var Path = new Path(); Path.Add(fromMarker); Path.Add(toMarker); if (doesReturn) { Path.Add(returnMarker); } var sg = new SimGroup() { objname = name }; sg.Add(Path); sg.Add(platform); return(sg); }
public static SimGroup MovingPlatform(string interior, int index, List <Marker> markers) { var platform = new PathedInterior(interior, index, Vector.Zero, AngAxis.Identity, Vector.One); var simgroup = new SimGroup(); var path = new Path(); foreach (var marker in markers) { path.Add(marker); } simgroup.Add(path); simgroup.Add(platform); return(simgroup); }
public SimGroup Import(string filename) { var rawMission = File.ReadLines(filename).ToList(); rawMission = rawMission.GetRange(rawMission.IndexOf("//--- OBJECT WRITE BEGIN ---"), rawMission.IndexOf("//--- OBJECT WRITE END ---") - rawMission.IndexOf("//--- OBJECT WRITE BEGIN ---") + 1); SimObject curobj = null; var status = new ImportStatus(); int curpos = 0; int bracestartindex = 0; int braceendindex = 0; int braceskip = 0; for (var i = 0; i < rawMission.Count; i++) { var a = rawMission[i]; rawMission[i] = a.Trim(); if (rawMission[i].Contains("//")) { rawMission[i] = rawMission[i].Split(new string[] { "//" }, StringSplitOptions.None)[0]; } } status = ImportStatus.Class; foreach (var line in rawMission) { string l = line; if (l.Contains("new") && status == ImportStatus.Class) { var raw = l.Split(' ')[1]; var objclass = raw.Substring(0, raw.IndexOf('(')); var name = raw.Substring(raw.IndexOf('(') + 1, raw.IndexOf(')') - raw.IndexOf('(') - 1); switch (objclass) { case "SimGroup": curobj = new SimGroup() { objname = name }; break; case "ScriptObject": curobj = new ScriptObject(name); break; case "Sky": curobj = new Sky() { objname = name }; break; case "Sun": curobj = new Sun() { objname = name }; break; case "Item": curobj = new Item() { objname = name }; break; case "InteriorInstance": curobj = new InteriorInstance() { objname = name }; break; case "Path": curobj = new Path() { objname = name }; break; case "Marker": curobj = new Marker() { objname = name }; break; case "PathedInterior": curobj = new PathedInterior() { objname = name }; break; case "Trigger": curobj = new Trigger() { objname = name }; break; case "StaticShape": curobj = new StaticShape() { objname = name }; break; default: curobj = new SimObject() { objname = name }; break; } status = ImportStatus.BracesStart; } if (status == ImportStatus.BracesStart) { if (l.Contains("{")) { bracestartindex = curpos; status = ImportStatus.BracesEnd; } } if (status == ImportStatus.BracesEnd) { if (l.Contains("{")) { braceskip++; } if (l.Contains("};")) { if (braceskip == 1) { braceendindex = curpos; status = ImportStatus.Children; var childlines = rawMission.GetRange(bracestartindex + 1, braceendindex - bracestartindex - 1); Import(childlines, ref curobj); } braceskip--; } } curpos++; } return(curobj as SimGroup); }
void Import(List <string> lines, ref SimObject parent) { SimObject curobj = null; var status = new ImportStatus(); status = ImportStatus.Properties; int bracestartindex = 0; int braceendindex = 0; int curpos = 0; int braceskip = 0; foreach (var line in lines) { string l = line; if (l.Contains("new") && status == ImportStatus.Properties) { var raw = l.Split(' ')[1]; var objclass = raw.Substring(0, raw.IndexOf('(')); var name = raw.Substring(raw.IndexOf('(') + 1, raw.IndexOf(')') - raw.IndexOf('(') - 1); switch (objclass) { case "SimGroup": curobj = new SimGroup() { objname = name }; break; case "ScriptObject": curobj = new ScriptObject(name); break; case "Sky": curobj = new Sky() { objname = name }; break; case "Sun": curobj = new Sun() { objname = name }; break; case "Item": curobj = new Item() { objname = name }; break; case "InteriorInstance": curobj = new InteriorInstance() { objname = name }; break; case "Path": curobj = new Path() { objname = name }; break; case "Marker": curobj = new Marker() { objname = name }; break; case "PathedInterior": curobj = new PathedInterior() { objname = name }; break; case "Trigger": curobj = new Trigger() { objname = name }; break; case "StaticShape": curobj = new StaticShape() { objname = name }; break; default: curobj = new SimObject() { objname = name }; break; } status = ImportStatus.BracesStart; (parent as SimGroup).Add(curobj); } if (status == ImportStatus.BracesStart) { if (l.Contains("{")) { bracestartindex = curpos; status = ImportStatus.BracesEnd; } } if (status == ImportStatus.BracesEnd) { if (l.Contains("{")) { braceskip++; } if (l.Contains("};")) { if (braceskip == 1) { braceendindex = curpos; status = ImportStatus.Children; var childlines = lines.GetRange(bracestartindex + 1, braceendindex - bracestartindex - 1); Import(childlines, ref curobj); status = ImportStatus.Properties; } braceskip--; } } if (l.Contains("=") && status == ImportStatus.Properties) { var property = l.Substring(0, l.IndexOf("=")).Trim(); var value = l.Substring(l.IndexOf("=") + 1, l.IndexOf(";") - l.IndexOf("=") - 1).Trim(); value = value.Trim('"'); parent[property] = value; } curpos++; } }