Code cleanup.

This commit is contained in:
2023-04-19 13:31:17 +08:00
parent f664708165
commit cf6a7a795b
9 changed files with 27 additions and 31 deletions

View File

@@ -38,11 +38,11 @@ namespace Cryville.Crtr.Event {
return r;
}
public void CopyTo(byte ct, EventBus dest) {
public void CopyTo(EventBus dest) {
base.CopyTo(dest);
dest.activeStates.Clear();
dest.invalidatedStates.Clear();
RootState.CopyTo(ct, dest.RootState);
RootState.CopyTo(dest.RootState);
dest.ValidateStates();
}
@@ -150,10 +150,10 @@ namespace Cryville.Crtr.Event {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
void HandleTempEvents(double time, int maxPriority = int.MaxValue) {
while (tempEvents.Count > 0) {
var ev2 = tempEvents[0];
if (ev2.Time != time || ev2.Priority >= maxPriority) break;
if (ev2.Container != null) {
states[ev2.Container].Handle(ev2);
var ev = tempEvents[0];
if (ev.Time != time || ev.Priority >= maxPriority) break;
if (ev.Container != null) {
states[ev.Container].Handle(ev);
}
tempEvents.RemoveAt(0);
}
@@ -178,6 +178,10 @@ namespace Cryville.Crtr.Event {
}
public void EndGraphicalUpdate() {
RootState.EndGraphicalUpdate();
ClearTempEvents();
}
void ClearTempEvents() {
foreach (var ev in tempEvents) {
if (ev.Container != null) {
states[ev.Container].Discard(ev);