public void FuseSegments() { var newChart = new List <BuffSegment>(); BuffSegment last = null; foreach (BuffSegment seg in BuffChart) { if (seg.Start == seg.End) { continue; } if (last == null) { newChart.Add(new BuffSegment(seg)); last = newChart.Last(); } else { if (seg.Value == last.Value) { last.End = seg.End; } else { newChart.Add(new BuffSegment(seg)); last = newChart.Last(); } } } BuffChart = newChart; }
public int GetStackCount(long time) { for (int i = BuffChart.Count - 1; i >= 0; i--) { BuffSegment seg = BuffChart[i]; if (seg.Start <= time && time <= seg.End) { return(seg.Value); } } return(0); }
public BuffSegment(BuffSegment other) : this(other.Start, other.End, other.Value) { }