Code cleanup.
This commit is contained in:
@@ -10,16 +10,17 @@ namespace Cryville.Crtr.Event {
|
||||
private set;
|
||||
}
|
||||
readonly Chart chart;
|
||||
ContainerState rootState;
|
||||
readonly Dictionary<ChartEvent, ContainerState> containerMap
|
||||
= new Dictionary<ChartEvent, ContainerState>();
|
||||
readonly Dictionary<EventContainer, ContainerState> stateMap
|
||||
= new Dictionary<EventContainer, ContainerState>();
|
||||
readonly Dictionary<ChartEvent, StampedEvent> map
|
||||
= new Dictionary<ChartEvent, StampedEvent>();
|
||||
public Dictionary<EventContainer, List<StampedEvent>> coeventMap
|
||||
readonly Dictionary<EventContainer, List<StampedEvent>> coeventMap
|
||||
= new Dictionary<EventContainer, List<StampedEvent>>();
|
||||
public HashSet<ChartEvent> coevents = new HashSet<ChartEvent>();
|
||||
public List<StampedEvent> stampedEvents = new List<StampedEvent>();
|
||||
readonly HashSet<ChartEvent> coevents = new HashSet<ChartEvent>();
|
||||
readonly List<StampedEvent> stampedEvents = new List<StampedEvent>();
|
||||
readonly List<EventBatch> batches = new List<EventBatch>();
|
||||
|
||||
double beat;
|
||||
@@ -29,10 +30,10 @@ namespace Cryville.Crtr.Event {
|
||||
chart = c;
|
||||
beat = chart.BeatPosition;
|
||||
tempo = (float)c.sigs[0].tempo;
|
||||
events.Add(c);
|
||||
events.Add(c.ReleaseEvent);
|
||||
Events.Add(c);
|
||||
Events.Add(c.ReleaseEvent);
|
||||
AddEventContainer(c);
|
||||
events.Sort((a, b) => a.BeatPosition.CompareTo(b.BeatPosition));
|
||||
Events.Sort((a, b) => a.BeatPosition.CompareTo(b.BeatPosition));
|
||||
}
|
||||
|
||||
void AddEventContainer(EventContainer c, ContainerState parent = null) {
|
||||
@@ -40,7 +41,7 @@ namespace Cryville.Crtr.Event {
|
||||
stateMap.Add(c, cs);
|
||||
if (parent == null) {
|
||||
cs.Depth = 0;
|
||||
RootState = cs;
|
||||
rootState = cs;
|
||||
}
|
||||
else {
|
||||
cs.Depth = (ushort)(parent.Depth + 1);
|
||||
@@ -53,10 +54,10 @@ namespace Cryville.Crtr.Event {
|
||||
ev.endtime = c.endtime;
|
||||
}
|
||||
if (ev.IsLong) {
|
||||
events.Add(ev.ReleaseEvent);
|
||||
Events.Add(ev.ReleaseEvent);
|
||||
containerMap.Add(ev.ReleaseEvent, cs);
|
||||
}
|
||||
events.Add(ev);
|
||||
Events.Add(ev);
|
||||
containerMap.Add(ev, cs);
|
||||
if (ev is EventContainer)
|
||||
AddEventContainer((EventContainer)ev, cs);
|
||||
@@ -65,9 +66,9 @@ namespace Cryville.Crtr.Event {
|
||||
|
||||
public override void ForwardOnceToTime(double toTime) {
|
||||
double toBeat = Math.Round(beat + (toTime - Time) * tempo / 60f, 6);
|
||||
if (EventId >= events.Count)
|
||||
if (EventId >= Events.Count)
|
||||
goto return_ahead;
|
||||
double ebeat = events[EventId].BeatPosition;
|
||||
double ebeat = Events[EventId].BeatPosition;
|
||||
double etime = Math.Round((ebeat - beat) / tempo * 60f + Time, 6);
|
||||
if (etime > toTime)
|
||||
goto return_ahead;
|
||||
@@ -113,18 +114,18 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
|
||||
IOrderedEnumerable<ChartEvent> GetEventBatch() {
|
||||
float cbeat = events[EventId].BeatPosition;
|
||||
float cbeat = Events[EventId].BeatPosition;
|
||||
int b = EventId;
|
||||
while (Mathf.Approximately(events[b].BeatPosition, cbeat)) {
|
||||
while (Mathf.Approximately(Events[b].BeatPosition, cbeat)) {
|
||||
b--;
|
||||
if (b == -1) break;
|
||||
}
|
||||
int a = EventId;
|
||||
while (Mathf.Approximately(events[a].BeatPosition, cbeat)) {
|
||||
while (Mathf.Approximately(Events[a].BeatPosition, cbeat)) {
|
||||
a++;
|
||||
if (a == events.Count) break;
|
||||
if (a == Events.Count) break;
|
||||
}
|
||||
return from ev in events.GetRange(b + 1, a - b - 1) orderby ev.Priority select ev;
|
||||
return from ev in Events.GetRange(b + 1, a - b - 1) orderby ev.Priority select ev;
|
||||
}
|
||||
|
||||
public EventBus Batch() {
|
||||
@@ -139,7 +140,7 @@ namespace Cryville.Crtr.Event {
|
||||
BatchCoevents(ev);
|
||||
}
|
||||
batches.Add(cb);
|
||||
Bus = new EventBus(chart, RootState, batches);
|
||||
Bus = new EventBus(rootState, batches);
|
||||
return Bus;
|
||||
}
|
||||
|
||||
|
@@ -125,7 +125,7 @@ namespace Cryville.Crtr.Event {
|
||||
}
|
||||
|
||||
public override void ForwardOnceToTime(double toTime) {
|
||||
double time1 = EventId < events.Count ? events[EventId].Time : double.PositiveInfinity;
|
||||
double time1 = EventId < Events.Count ? Events[EventId].Time : double.PositiveInfinity;
|
||||
double time2 = tempEvents.Count > 0 ? tempEvents[0].Time : double.PositiveInfinity;
|
||||
double time0 = Math.Min(time1, time2);
|
||||
if (time0 <= toTime && time0 != double.PositiveInfinity) {
|
||||
@@ -133,7 +133,7 @@ namespace Cryville.Crtr.Event {
|
||||
foreach (var s in workingStates) s.Handle(null);
|
||||
ValidateStates();
|
||||
if (time1 == time0) {
|
||||
var batch = events[EventId];
|
||||
var batch = Events[EventId];
|
||||
for (var i = 0; i < batch.Count; i++) {
|
||||
var ev = batch[i];
|
||||
if (ev.Container != null) {
|
||||
|
Reference in New Issue
Block a user