scripts
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UnityEngine.Experimental.UIElements
|
||||
{
|
||||
// Token: 0x02000342 RID: 834
|
||||
internal class TimerEventScheduler : IScheduler
|
||||
{
|
||||
// Token: 0x06003397 RID: 13207 RVA: 0x00050F64 File Offset: 0x0004F164
|
||||
private void Schedule(ScheduledItem scheduleItem)
|
||||
{
|
||||
if (this.m_ScheduledItems.Contains(scheduleItem))
|
||||
{
|
||||
Debug.LogError("Cannot schedule function " + scheduleItem.timerUpdateEvent + " more than once");
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_ScheduledItems.Add(scheduleItem);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06003398 RID: 13208 RVA: 0x00050FB4 File Offset: 0x0004F1B4
|
||||
public ScheduleBuilder Schedule(Action<TimerState> timerUpdateEvent, IEventHandler handler)
|
||||
{
|
||||
ScheduledItem scheduledItem = new ScheduledItem(timerUpdateEvent, handler);
|
||||
if (this.m_TransactionMode)
|
||||
{
|
||||
this.m_ScheduleTansactions.Add(scheduledItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Schedule(scheduledItem);
|
||||
}
|
||||
return new ScheduleBuilder(scheduledItem);
|
||||
}
|
||||
|
||||
// Token: 0x06003399 RID: 13209 RVA: 0x00051000 File Offset: 0x0004F200
|
||||
public void Unschedule(Action<TimerState> timerUpdateEvent)
|
||||
{
|
||||
if (this.m_TransactionMode)
|
||||
{
|
||||
this.m_UnscheduleTransactions.Add(timerUpdateEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
ScheduledItem scheduledItem = this.m_ScheduledItems.Find((ScheduledItem t) => t.timerUpdateEvent == timerUpdateEvent);
|
||||
if (scheduledItem != null)
|
||||
{
|
||||
this.m_ScheduledItems.Remove(scheduledItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Cannot unschedule unknown scheduled function " + timerUpdateEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0600339A RID: 13210 RVA: 0x00051088 File Offset: 0x0004F288
|
||||
public void UpdateScheduledEvents()
|
||||
{
|
||||
try
|
||||
{
|
||||
this.m_TransactionMode = true;
|
||||
long num = (long)(Time.realtimeSinceStartup * 1000f);
|
||||
for (int i = 0; i < this.m_ScheduledItems.Count; i++)
|
||||
{
|
||||
ScheduledItem scheduledItem = this.m_ScheduledItems[i];
|
||||
if (scheduledItem.handler.panel == null)
|
||||
{
|
||||
Debug.Log("Will unschedule action of " + scheduledItem.handler + " because it has no panel");
|
||||
this.Unschedule(scheduledItem.timerUpdateEvent);
|
||||
}
|
||||
else if (scheduledItem.IsUpdatable())
|
||||
{
|
||||
TimerState timerState = new TimerState
|
||||
{
|
||||
start = scheduledItem.start,
|
||||
now = num
|
||||
};
|
||||
if (num - scheduledItem.delay > scheduledItem.start)
|
||||
{
|
||||
if (scheduledItem.timerUpdateEvent != null)
|
||||
{
|
||||
scheduledItem.timerUpdateEvent(timerState);
|
||||
}
|
||||
scheduledItem.start = num;
|
||||
scheduledItem.delay = scheduledItem.interval;
|
||||
if (scheduledItem.timerUpdateStopCondition != null && scheduledItem.timerUpdateStopCondition())
|
||||
{
|
||||
this.Unschedule(scheduledItem.timerUpdateEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
this.m_TransactionMode = false;
|
||||
for (int j = 0; j < this.m_UnscheduleTransactions.Count; j++)
|
||||
{
|
||||
this.Unschedule(this.m_UnscheduleTransactions[j]);
|
||||
}
|
||||
this.m_UnscheduleTransactions.Clear();
|
||||
for (int k = 0; k < this.m_ScheduleTansactions.Count; k++)
|
||||
{
|
||||
this.Schedule(this.m_ScheduleTansactions[k]);
|
||||
}
|
||||
this.m_ScheduleTansactions.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x04000AAB RID: 2731
|
||||
private readonly List<ScheduledItem> m_ScheduledItems = new List<ScheduledItem>();
|
||||
|
||||
// Token: 0x04000AAC RID: 2732
|
||||
private bool m_TransactionMode;
|
||||
|
||||
// Token: 0x04000AAD RID: 2733
|
||||
private readonly List<ScheduledItem> m_ScheduleTansactions = new List<ScheduledItem>();
|
||||
|
||||
// Token: 0x04000AAE RID: 2734
|
||||
private readonly List<Action<TimerState>> m_UnscheduleTransactions = new List<Action<TimerState>>();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user