public AccessoryShapeComponent(DocumentParser sr) { points = new List<Vector3>(); string s = sr.ReadNextLine(); int pointCount; switch (s) { case "AlignedCuboid": this.componentType = ComponentType.AlignedCuboid; points.Add(sr.ReadVector3()); points.Add(sr.ReadVector3()); break; case "Polyhedron": this.componentType = ComponentType.Polyhedron; pointCount = sr.ReadInt(); for (int i = 0; i < pointCount; i++) { points.Add(sr.ReadVector3()); } break; case "RoundedPolyhedron": this.componentType = ComponentType.RoundedPolyhedron; radius = sr.ReadFloat(); pointCount = sr.ReadInt(); for (int i = 0; i < pointCount; i++) { points.Add(sr.ReadVector3()); } break; case "Sphere": points.Add(sr.ReadVector3()); radius = sr.ReadFloat(); break; case "TicTac": points.Add(sr.ReadVector3()); points.Add(sr.ReadVector3()); radius = sr.ReadFloat(); break; default: throw new NotImplementedException("Unknown ComponentType: " + s); } while (sr.ReadNextLine() == "form_collision_groups") { group = sr.ReadInt(); } sr.Rewind(); }
public AccessoryBreak(DocumentParser sr) { bool bBreak = true; string[] settings; string line; if (!Accessory.TestLine("Breakable", sr.ReadNextLine(), out line)) { Console.WriteLine("Unexpected value: {0}", line); } while (bBreak) { line = sr.ReadNextLine(); if (line == null) { break; } settings = line.Split(' '); switch (settings[0].ToLower()) { case "break": case "break_impulse": breakImpulse = settings[settings.Length - 1].ToInt(); break; case "detach_children": case "detatch_children": bDetatchChildren = true; break; case "destroy_children": bDestroyChildren = true; break; case "explode": case "explode_force": explodeForce = settings[settings.Length - 1].ToInt(); break; case "random_rotation": if (settings.Length == 2) { randomRotation = Vector2.Parse(settings[1]); } else { randomRotation = new Vector2(settings[1].ToSingle(), settings[2].ToSingle()); } break; case "sound": sound = settings[1]; break; case "trigger_particles": bTriggerParticles = true; break; case "collision_with_world_will_break_me": Console.WriteLine("collision_with_world_will_break_me: {0}", settings[1]); break; case "replace": if (settings.Length == 3) { replacements.Add(new AccessoryBreakReplacement(settings[1], settings[2])); } else { replacements.Add(new AccessoryBreakReplacement(settings[1])); } break; default: bBreak = false; if (!settings[0].StartsWith("[") && !settings[0].StartsWith("<")) { Console.WriteLine("Unexpected setting: {0}", settings[0]); } else { sr.Rewind(); } break; } } }