本文整理汇总了C#中VRage.Library.Utils.MyTimeSpan类的典型用法代码示例。如果您正苦于以下问题:C# MyTimeSpan类的具体用法?C# MyTimeSpan怎么用?C# MyTimeSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyTimeSpan类属于VRage.Library.Utils命名空间,在下文中一共展示了MyTimeSpan类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateSleep
public void UpdateSleep(bool isRelevant, MyTimeSpan currentTime)
{
if (isRelevant)
SleepTime = MyTimeSpan.Zero;
else if (!IsSleeping)
SleepTime = currentTime;
}
示例2: BeforeRender
public void BeforeRender(MyTimeSpan? currentDrawTime)
{
using (m_lock.Acquire())
{
if (currentDrawTime.HasValue)
MyRenderProxy.CurrentDrawTime = currentDrawTime.Value;
}
}
示例3: ReadAndClear
public void ReadAndClear(MyTimeSpan currentTime, out Value sum, out int count, out Value min, out Value max, out Value last, out MyStatTypeEnum type, out int decimals, out MyTimeSpan inactivityMs)
{
Lock.Enter();
try
{
inactivityMs = MyTimeSpan.Zero;
if (Count <= 0) // Nothing was written
{
// Load delta, increment it and save it
var delta = IntToDeltaTime(-Count);
delta += Count < 0 ? currentTime - LastClear : MyTimeSpan.FromMiliseconds(1);
Count = -DeltaTimeToInt(delta);
inactivityMs = delta;
LastClear = currentTime; // Nothing was written, postpone clear
}
else
{
if (currentTime >= (LastRefresh + MyTimeSpan.FromMiliseconds(RefreshRate)))
{
DrawSum = Sum;
DrawCount = Count;
DrawMin = Min;
DrawMax = Max;
DrawLast = Last;
LastRefresh = currentTime;
if (ClearRate == -1) // Clear with refresh
{
Count = 0;
ClearUnsafe();
}
}
if (ClearRate != -1 && currentTime >= (LastClear + MyTimeSpan.FromMiliseconds(ClearRate)))
{
Count = 0;
ClearUnsafe();
LastClear = currentTime;
}
}
type = Type;
decimals = NumDecimals;
}
finally
{
Lock.Exit();
}
// No need lock, not accessed anywhere else outside read
sum = DrawSum;
count = DrawCount;
min = DrawMin;
max = DrawMax;
last = DrawLast;
}
示例4: SetHealth
private void SetHealth(float health)
{
if (health<20)
//play heavy breath indefinitely
m_healthOverride = MyTimeSpan.MaxValue;
else
if (health<100)
m_healthOverride = MySandboxGame.Static.UpdateTime + MyTimeSpan.FromSeconds(300 / (health - 19.99));
Update(true);
}
示例5: BeforeRender
public void BeforeRender(MyRenderSettings writeTo, MyTimeSpan? currentDrawTime)
{
using (m_lock.Acquire())
{
if (currentDrawTime.HasValue)
MyRenderProxy.CurrentDrawTime = currentDrawTime.Value;
writeTo.Synchronize(m_inputRenderSettings);
}
}
示例6: AfterUpdate
public void AfterUpdate(MyTimeSpan? updateTimestamp)
{
using (m_lock.Acquire())
{
if (updateTimestamp.HasValue)
m_inputRenderMessages.CurrentUpdateFrame.UpdateTimestamp = updateTimestamp.Value;
m_inputRenderMessages.CommitUpdateFrame();
m_inputBillboards.CommitWrite();
m_inputBillboards.Write.Clear();
m_inputTriangleBillboards.CommitWrite();
m_inputTriangleBillboards.Write.Clear();
}
}
示例7: AfterUpdate
public void AfterUpdate(MyRenderSettings inputSettings, MyTimeSpan? updateTimestamp)
{
using (m_lock.Acquire())
{
if (updateTimestamp.HasValue)
m_inputRenderMessages.CurrentUpdateFrame.UpdateTimestamp = updateTimestamp.Value;
m_inputRenderMessages.CommitUpdateFrame();
m_inputRenderSettings.Synchronize(inputSettings); // TODO: OP! Better settings synchronization
m_inputBillboards.CommitWrite();
m_inputBillboards.Write.Clear();
m_inputTriangleBillboards.CommitWrite();
m_inputTriangleBillboards.Write.Clear();
}
}
示例8: EndProfileBlock
public static void EndProfileBlock()
{
Block ended = ProfileValues.m_block.Pop();
MyTimeSpan elapsed = new MyTimeSpan(ProfileValues.m_timer.ElapsedTicks - ended.Started);
using (ProfileValues.m_lock.AcquireExclusiveUsing())
{
Stats s;
if (!ProfileValues.m_profile.TryGetValue(ended.Name, out s))
{
s = new Stats();
ProfileValues.m_profile.Add(ended.Name, s);
}
s.TimeSpent += elapsed;
s.Invokes++;
if (ProfileValues.m_block.Count == 0)
ProfileValues.m_total.TimeSpent += elapsed;
ProfileValues.m_total.Invokes++;
}
}
示例9: Results
/// <summary>
/// Create Results from a List of execution times.
/// </summary>
/// <param name="executionTimes">Execution times. Results does not create a copy, so the list should not be changed.</param>
internal Results(ListSnapshots<MyTimeSpan> executionTimes)
{
UnsortedResults = executionTimes.immutable();
Count = UnsortedResults.Count;
Lazy_SortedResults = new Lazy<ReadOnlyList<MyTimeSpan>>(() =>
{
executionTimes.mutable().Sort((MyTimeSpan first, MyTimeSpan second) => { return Math.Sign((first - second).Ticks); });
return new ReadOnlyList<MyTimeSpan>(executionTimes.immutable());
});
Lazy_Total = new Lazy<MyTimeSpan>(() =>
{
MyTimeSpan sum = new MyTimeSpan(0);
foreach (MyTimeSpan result in UnsortedResults)
sum += result;
return sum;
});
Lazy_Mean = new Lazy<MyTimeSpan>(() => { return new MyTimeSpan(Total.Ticks / Count); });
Lazy_Median = new Lazy<MyTimeSpan>(() => SortedResults_Interpolate((decimal)Count / 2 - 0.5m));
Lazy_FirstQuartile = new Lazy<MyTimeSpan>(() => SortedResults_Interpolate((decimal)Count / 4 - 0.5m));
Lazy_ThirdQuartile = new Lazy<MyTimeSpan>(() => SortedResults_Interpolate((decimal)Count * 3 / 4 - 0.5m));
}
示例10: InfinarioUpdate
public static void InfinarioUpdate(MyTimeSpan updateTime)
{
if (updateTime.Seconds - 60f >= m_lastMinuteUpdate)
{
m_lastMinuteUpdate = (float)updateTime.Seconds;
ReportServerStatus();
}
}
示例11: Log
public void Log(MyTimeSpan currentTime)
{
Time += currentTime - TimeStamp;
TotalTime += currentTime - TimeStamp;
}
示例12: SetViewMatrix
public static void SetViewMatrix(MatrixD value, MyTimeSpan? updateTime)
{
if (MyRender.Settings.EnableCameraInterpolation && updateTime.HasValue)
{
var world = MatrixD.Invert(value);
m_interpolation.AddSample(ref world, updateTime.Value);
MatrixD worldOut;
float i = m_interpolation.Interpolate(MyRender.InterpolationTime, out worldOut);
m_viewMatrix = MatrixD.Invert(worldOut);
MyRenderStats.Generic.Write("Camera interpolator", i, MyStatTypeEnum.Max, 250, 2);
SetPosition(worldOut.Translation);
}
else
{
m_viewMatrix = value;
MatrixD invertedViewMatrix;
MatrixD.Invert(ref m_viewMatrix, out invertedViewMatrix);
SetPosition(invertedViewMatrix.Translation);
}
InversePositionTranslationMatrix = MatrixD.CreateTranslation(-Position);
}
示例13: ProfileCustomValue
public void ProfileCustomValue(string name, float value, MyTimeSpan? customTime = null, string timeFormat = null, string valueFormat = null, [CallerMemberName] string member = "", [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
{
if (m_levelLimit != -1)
{
return;
}
ThreadProfiler.ProfileCustomValue(name, member, line, file, value, customTime, timeFormat, valueFormat);
}
示例14: End
public static void End(float customValue = 0, MyTimeSpan? customTime = null, string timeFormat = null, string valueFormat = null, [CallerMemberName] string member = "", [CallerLineNumber] int line = 0, [CallerFilePath] string file = "")
{
MyRenderProxy.GetRenderProfiler().EndProfilingBlock(customValue, customTime, timeFormat, valueFormat, member, line, file);
}
示例15: ProfileCustomValue
public void ProfileCustomValue(string name, string member, int line, string file, float value, MyTimeSpan? customTime, string timeFormat, string valueFormat, string callFormat = null)
{
StartBlock(name, member, line, file);
EndBlock(member, line, file, customTime, value, timeFormat, valueFormat, callFormat);
}