scripts
This commit is contained in:
@@ -0,0 +1,143 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace UnityEngine
|
||||
{
|
||||
// Token: 0x02000007 RID: 7
|
||||
internal class IntervalNode
|
||||
{
|
||||
// Token: 0x06000037 RID: 55 RVA: 0x00003A64 File Offset: 0x00001C64
|
||||
public IntervalNode(IEnumerable<IInterval> items)
|
||||
{
|
||||
List<long> list = new List<long>();
|
||||
foreach (IInterval interval in items)
|
||||
{
|
||||
list.Add(interval.intervalStart);
|
||||
list.Add(interval.intervalEnd);
|
||||
}
|
||||
if (list.Count != 0)
|
||||
{
|
||||
list.Sort();
|
||||
this.m_Center = list[list.Count / 2];
|
||||
this.m_Children = new List<IInterval>();
|
||||
List<IInterval> list2 = new List<IInterval>();
|
||||
List<IInterval> list3 = new List<IInterval>();
|
||||
foreach (IInterval interval2 in items)
|
||||
{
|
||||
long intervalStart = interval2.intervalStart;
|
||||
if (interval2.intervalEnd.CompareTo(this.m_Center) < 0)
|
||||
{
|
||||
list2.Add(interval2);
|
||||
}
|
||||
else if (intervalStart.CompareTo(this.m_Center) > 0)
|
||||
{
|
||||
list3.Add(interval2);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Children.Add(interval2);
|
||||
}
|
||||
}
|
||||
if (this.m_Children.Count > 0)
|
||||
{
|
||||
this.m_Children = this.m_Children.OrderBy((IInterval c) => c.intervalStart).ToList<IInterval>();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_Children = null;
|
||||
}
|
||||
if (list2.Count > 0)
|
||||
{
|
||||
this.m_LeftNode = new IntervalNode(list2);
|
||||
}
|
||||
if (list3.Count > 0)
|
||||
{
|
||||
this.m_RightNode = new IntervalNode(list3);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000038 RID: 56 RVA: 0x00003C44 File Offset: 0x00001E44
|
||||
public void Query<U>(long time, int bitflag, ref List<U> results) where U : class, IInterval
|
||||
{
|
||||
if (this.m_Children != null)
|
||||
{
|
||||
for (int i = 0; i < this.m_Children.Count; i++)
|
||||
{
|
||||
U u = this.m_Children[i] as U;
|
||||
if (u != null)
|
||||
{
|
||||
long intervalStart = u.intervalStart;
|
||||
long intervalEnd = u.intervalEnd;
|
||||
if (intervalStart.CompareTo(time) > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (time.CompareTo(intervalStart) >= 0 && time.CompareTo(intervalEnd) < 0)
|
||||
{
|
||||
u.intervalBit = bitflag;
|
||||
results.Add(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (time.CompareTo(this.m_Center) < 0 && this.m_LeftNode != null)
|
||||
{
|
||||
this.m_LeftNode.Query<U>(time, bitflag, ref results);
|
||||
}
|
||||
else if (time.CompareTo(this.m_Center) > 0 && this.m_RightNode != null)
|
||||
{
|
||||
this.m_RightNode.Query<U>(time, bitflag, ref results);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x06000039 RID: 57 RVA: 0x00003D64 File Offset: 0x00001F64
|
||||
public void Query<U>(long start, long end, int bitflag, ref List<U> results) where U : class, IInterval
|
||||
{
|
||||
long num = start;
|
||||
long num2 = end;
|
||||
if (this.m_Children != null)
|
||||
{
|
||||
for (int i = 0; i < this.m_Children.Count; i++)
|
||||
{
|
||||
U u = this.m_Children[i] as U;
|
||||
if (u != null)
|
||||
{
|
||||
long intervalStart = u.intervalStart;
|
||||
long intervalEnd = u.intervalEnd;
|
||||
if (intervalStart.CompareTo(num2) > 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (num2.CompareTo(intervalStart) >= 0 && intervalEnd.CompareTo(num) >= 0)
|
||||
{
|
||||
u.intervalBit = bitflag;
|
||||
results.Add(u);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num.CompareTo(this.m_Center) < 0 && this.m_LeftNode != null)
|
||||
{
|
||||
this.m_LeftNode.Query<U>(start, end, bitflag, ref results);
|
||||
}
|
||||
if (num2.CompareTo(this.m_Center) > 0 && this.m_RightNode != null)
|
||||
{
|
||||
this.m_RightNode.Query<U>(start, end, bitflag, ref results);
|
||||
}
|
||||
}
|
||||
|
||||
// Token: 0x0400000C RID: 12
|
||||
private long m_Center;
|
||||
|
||||
// Token: 0x0400000D RID: 13
|
||||
private List<IInterval> m_Children;
|
||||
|
||||
// Token: 0x0400000E RID: 14
|
||||
private IntervalNode m_LeftNode;
|
||||
|
||||
// Token: 0x0400000F RID: 15
|
||||
private IntervalNode m_RightNode;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user