WuhuIslandTesting/Library/PackageCache/com.unity.addressables@1.21.12/Editor/Diagnostics/Data/EventDataStream.cs

50 lines
1.5 KiB
C#
Raw Normal View History

2025-01-07 02:06:59 +01:00
using System;
using System.Collections.Generic;
using UnityEngine.AddressableAssets;
namespace UnityEditor.AddressableAssets.Diagnostics.Data
{
[Serializable]
class EventDataSetStream
{
internal int maxValue;
internal List<EventDataSample> samples = new List<EventDataSample>();
internal void AddSample(int frame, int val)
{
bool streamHasSamples = samples.Count > 0;
if (streamHasSamples && frame < samples[samples.Count - 1].frame)
return;
if (val > maxValue)
maxValue = val;
if (streamHasSamples && samples[samples.Count - 1].frame == frame)
samples[samples.Count - 1] = new EventDataSample(frame, val);
else
samples.Add(new EventDataSample(frame, val));
}
internal int GetValue(int f)
{
if (samples.Count == 0 || f < samples[0].frame)
return 0;
if (f >= samples[samples.Count - 1].frame)
return samples[samples.Count - 1].data;
for (int i = 1; i < samples.Count; i++)
{
if (samples[i].frame > f)
return samples[i - 1].data;
}
return samples[0].data;
}
internal bool HasDataAfterFrame(int frame)
{
if (samples.Count == 0)
return false;
EventDataSample lastSample = samples[samples.Count - 1];
return lastSample.frame > frame || lastSample.data > 0;
}
}
}