//Gets the list of positions and times for each note of the beatmap, so that //other methods can use these lists without continuous calculations private void GetPositionsAndTimes() { List <int> positionslist = new List <int>(); List <int> timeslist = new List <int>(); for (int i = 0; i < hitobjects.GetSize(); i++) { try { GenericHitObject hobject = new GenericHitObject(hitobjects.GetHitObjectID(i), map); positionslist.AddRange(hobject.GetHitLocations()); timeslist.AddRange(hobject.GetHitTimes()); } catch (Exception e) { //This is zero-indexed, so the first object is object=0 throw new Exception(e.Message + "\nobject=" + i, e); } } if (positionslist.Count != timeslist.Count) { throw new Exception("Error: position and times array mismatched in size\n" + "positions.Count: " + positionslist.Count + "\n" + "times.Count: " + timeslist.Count); } this.positions = positionslist.ToArray(); this.times = timeslist.ToArray(); }
public HitPointParser(string filename) { map = new Beatmap(filename); if (map.GetTag("general", "mode") == "3") { throw new ArgumentException("Error, mania mode parsing not supported"); } List <HitPoint> hitpointbuffer = new List <HitPoint>(); string[] hitobjectids = map.GetSection("hitobjects"); for (int i = 0; i < hitobjectids.Length; i++) { try { GenericHitObject hobject = new GenericHitObject(hitobjectids[i], map); int[] positions = hobject.GetHitLocations(); int[] times = hobject.GetHitTimes(); if (positions.Length != times.Length) { throw new Exception("Error: position and times array mismatched in size\n" + "positions.Length: " + positions.Length + "\n" + "times.Length: " + times.Length + "\n" + "index: " + i); } //Add a new HitPoint for every hit position and time for (int j = 0; j < positions.Length; j++) { HitPoint point = new HitPoint(positions[j], times[j], 0, 0); hitpointbuffer.Add(point); } } catch (Exception e) { //This is zero-indexed, so the first object is object=0 throw new Exception(e.Message + "\nobject=" + i + "\n" + GetMetadata("title") + ": " + GetMetadata("version"), e); } } hitpoints = hitpointbuffer.ToArray(); }