本文整理汇总了C#中VRage.Library.Utils.MyTimeSpan类的典型用法代码示例。如果您正苦于以下问题:C# MyTimeSpan类的具体用法?C# MyTimeSpan怎么用?C# MyTimeSpan使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MyTimeSpan类属于VRage.Library.Utils命名空间,在下文中一共展示了MyTimeSpan类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: UpdateSleep
public void UpdateSleep(bool isRelevant, MyTimeSpan currentTime)
{
if (isRelevant)
SleepTime = MyTimeSpan.Zero;
else if (!IsSleeping)
SleepTime = currentTime;
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:7,代码来源:MyReplicableClientData.cs
示例2: BeforeRender
public void BeforeRender(MyTimeSpan? currentDrawTime)
{
using (m_lock.Acquire())
{
if (currentDrawTime.HasValue)
MyRenderProxy.CurrentDrawTime = currentDrawTime.Value;
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:8,代码来源:MySharedData.cs
示例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;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:58,代码来源:MyStat.cs
示例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);
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:10,代码来源:MyCharacterBreath.cs
示例5: BeforeRender
public void BeforeRender(MyRenderSettings writeTo, MyTimeSpan? currentDrawTime)
{
using (m_lock.Acquire())
{
if (currentDrawTime.HasValue)
MyRenderProxy.CurrentDrawTime = currentDrawTime.Value;
writeTo.Synchronize(m_inputRenderSettings);
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:10,代码来源:MySharedData.cs
示例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();
}
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:14,代码来源:MySharedData.cs
示例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();
}
}
开发者ID:fluxit,项目名称:SpaceEngineers,代码行数:15,代码来源:MySharedData.cs
示例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++;
}
}
开发者ID:Souper07,项目名称:Autopilot,代码行数:21,代码来源:Profiler.cs
示例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));
}
开发者ID:helppass,项目名称:Autopilot,代码行数:28,代码来源:TimeAction.cs
示例10: InfinarioUpdate
public static void InfinarioUpdate(MyTimeSpan updateTime)
{
if (updateTime.Seconds - 60f >= m_lastMinuteUpdate)
{
m_lastMinuteUpdate = (float)updateTime.Seconds;
ReportServerStatus();
}
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:8,代码来源:MyAnalyticsHelper.cs
示例11: Log
public void Log(MyTimeSpan currentTime)
{
Time += currentTime - TimeStamp;
TotalTime += currentTime - TimeStamp;
}
开发者ID:2asoft,项目名称:SpaceEngineers,代码行数:5,代码来源:MySimpleProfiler.cs
示例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);
}
开发者ID:Krulac,项目名称:SpaceEngineers,代码行数:24,代码来源:MyRenderCamera.cs
示例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);
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:9,代码来源:MyRenderProfiler.cs
示例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);
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:4,代码来源:ProfilerShort.cs
示例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);
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:5,代码来源:MyProfiler.cs
示例16: MyShipConnector
public MyShipConnector()
{
#if XB1 // XB1_SYNC_NOREFLECTION
ThrowOut = SyncType.CreateAndAddProp<bool>();
CollectAll = SyncType.CreateAndAddProp<bool>();
Strength = SyncType.CreateAndAddProp<float>();
m_connectionState = SyncType.CreateAndAddProp<State>();
#endif // XB1
CreateTerminalControls();
m_connectionState.ValueChanged += (o) => OnConnectionStateChanged();
m_connectionState.ValidateNever(); // Never set by client
m_manualDisconnectTime = new MyTimeSpan(-DisconnectSleepTime.Ticks);
Strength.Validate = (o) => Strength >= 0 && Strength <= 1;
}
开发者ID:ChristianHeinz71,项目名称:SpaceEngineers,代码行数:15,代码来源:MyShipConnector.cs
示例17: BeforeRender
// TODO: OP! make time mandatory
public static void BeforeRender(MyTimeSpan? currentDrawTime)
{
m_render.SharedData.BeforeRender(m_render.Settings, currentDrawTime);
}
开发者ID:stanhebben,项目名称:SpaceEngineers,代码行数:5,代码来源:MyRenderProxy.cs
示例18: EndBlock
public void EndBlock(string member, int line, string file, MyTimeSpan? customTime = null, float customValue = 0, string timeFormat = null, string valueFormat = null, string callFormat = null)
{
Debug.Assert(!EnableAsserts || OwnerThread == Thread.CurrentThread);
if (m_levelSkipCount > 0)
{
m_levelSkipCount--;
return;
}
if (m_currentProfilingStack.Count > 0)
{
MyProfilerBlock profilingBlock = m_currentProfilingStack.Pop();
CheckEndBlock(profilingBlock, member, file, GetParentId());
profilingBlock.CustomValue = customValue;
profilingBlock.TimeFormat = timeFormat;
profilingBlock.ValueFormat = valueFormat;
profilingBlock.CallFormat = callFormat;
profilingBlock.End(MemoryProfiling, customTime);
}
else
{
Debug.Fail(String.Format("Unpaired profiling end block encountered for '{0}'{1}File: {2}({3}){1}", member, Environment.NewLine, file, line));
}
if (AutoCommit && m_currentProfilingStack.Count == 0)
CommitInternal();
}
开发者ID:Chrus,项目名称:SpaceEngineers,代码行数:28,代码来源:MyProfiler.cs
示例19: Update
/// <summary>
/// Updates resource.
/// </summary>
public void Update(MyTimeSpan updateTime)
{
CheckUpdate();
CheckProfilerDump();
ProfilerShort.Begin("Parallel.RunCallbacks");
ParallelTasks.Parallel.RunCallbacks();
ProfilerShort.End();
TimeSpan elapsedTimespan = new TimeSpan(0, 0, 0, 0, (int)(MyEngineConstants.UPDATE_STEP_SIZE_IN_MILLISECONDS));
// Prevent update when game is paused
if (m_updateAllowed || Engine.Platform.Game.IsDedicated)
{
if (MySandboxGame.IsPaused)
{
return;
}
UpdateComponents();
MyParticleEffects.UpdateEffects();
ProfilerShort.Begin("Multiplayer.Tick");
if (MyMultiplayer.Static != null)
{
MyMultiplayer.Static.Tick();
}
ProfilerShort.End();
// update global game time
ElapsedGameTime += elapsedTimespan;
if (m_lastTimeMemoryLogged + TimeSpan.FromSeconds(30) < DateTime.UtcNow)
{
MySandboxGame.Log.WriteLine(String.Format("GC Memory: {0} B", GC.GetTotalMemory(false).ToString("##,#")));
m_lastTimeMemoryLogged = DateTime.UtcNow;
}
if (AutoSaveInMinutes > 0)
{
if (MySandboxGame.IsGameReady && (updateTime.TimeSpan - m_timeOfSave.TimeSpan) > TimeSpan.FromMinutes(AutoSaveInMinutes))
{
MySandboxGame.Log.WriteLine("Autosave initiated");
MyCharacter character = LocalCharacter;
bool canSave = (character != null && !character.IsDead) || character == null;
MySandboxGame.Log.WriteLine("Character state: " + canSave);
canSave &= Sync.IsServer;
MySandboxGame.Log.WriteLine("IsServer: " + Sync.IsServer);
canSave &= !MyAsyncSaving.InProgress;
MySandboxGame.Log.WriteLine("MyAsyncSaving.InProgress: " + MyAsyncSaving.InProgress);
if (canSave)
{
MySandboxGame.Log.WriteLineAndConsole("Autosave");
MyAsyncSaving.Start(() => MySector.ResetEyeAdaptation = true); //black screen after autosave
}
m_timeOfSave = updateTime;
}
}
if (MySandboxGame.IsGameReady && m_framesToReady > 0)
{
m_framesToReady--;
if (m_framesToReady == 0)
{
Ready = true;
MyAudio.Static.PlayMusic(new MyMusicTrack() { TransitionCategory = MyStringId.GetOrCompute("Default") });
if (OnReady != null)
OnReady();
if (OnReady != null)
foreach (var cb in OnReady.GetInvocationList())
{
OnReady -= (Action)cb;
}
if (Engine.Platform.Game.IsDedicated)
MyLog.Default.WriteLineAndConsole("Game ready... Press Ctrl+C to exit");
}
}
if (Sync.MultiplayerActive && !Sync.IsServer)
CheckMultiplayerStatus();
m_gameplayFrameCounter++;
}
// In pause, the only thing that needs update in the session is the character and third person spectator.
// This is a terrible hack and should be done more systematically
else
{
if (CameraController is MyThirdPersonSpectator)
{
(CameraController as MyThirdPersonSpectator).UpdateAfterSimulation();
}
//.........这里部分代码省略.........
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:101,代码来源:MySession.cs
示例20: MySession
/// <summary>
/// Initializes a new instance of the <see cref="MySession"/> class.
/// </summary>
private MySession(MySyncLayer syncLayer, bool registerComponents = true)
{
Debug.Assert(syncLayer != null);
if (syncLayer == null)
MyLog.Default.WriteLine("MySession.Static.MySession() - sync layer is null");
SyncLayer = syncLayer;
ElapsedGameTime = new TimeSpan();
// To reset spectator positions
Spectator.Reset();
m_timeOfSave = MyTimeSpan.Zero;
ElapsedGameTime = new TimeSpan();
Ready = false;
MultiplayerLastMsg = 0;
MultiplayerAlive = true;
MultiplayerDirect = true;
AppVersionFromSave = MyFinalBuildConstants.APP_VERSION;
Factions.FactionStateChanged += OnFactionsStateChanged;
ScriptManager = new MyScriptManager();
GC.Collect(2, GCCollectionMode.Forced);
MySandboxGame.Log.WriteLine(String.Format("GC Memory: {0} B", GC.GetTotalMemory(false).ToString("##,#")));
MySandboxGame.Log.WriteLine(String.Format("Process Memory: {0} B", Process.GetCurrentProcess().PrivateMemorySize64.ToString("##,#")));
this.GameFocusManager = new MyGameFocusManager();
}
开发者ID:liiir1985,项目名称:SpaceEngineers,代码行数:38,代码来源:MySession.cs
注:本文中的VRage.Library.Utils.MyTimeSpan类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论