Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
GameClock.cs
Go to the documentation of this file.
1using System;
3
5
6internal class GameClock
7{
8 private long baseRealTime;
9
10 private long lastRealTime;
11
12 private bool lastRealTimeValid;
13
14 private int suspendCount;
15
16 private long suspendStartTime;
17
19
21
23
25
27
29
31
33
35
36 internal static long Counter => Stopwatch.GetTimestamp();
37
38 internal static long Frequency => Stopwatch.Frequency;
39
40 public GameClock()
41 {
42 Reset();
43 }
44
45 internal void Reset()
46 {
50 lastRealTimeValid = false;
51 }
52
53 internal void UpdateElapsedTime()
54 {
55 long counter = Counter;
57 {
58 lastRealTime = counter;
59 lastRealTimeValid = true;
60 }
61 try
62 {
64 }
65 catch (OverflowException)
66 {
69 try
70 {
72 }
73 catch (OverflowException)
74 {
75 baseRealTime = counter;
77 }
78 }
79 try
80 {
82 }
83 catch (OverflowException)
84 {
86 }
87 try
88 {
91 }
92 catch (OverflowException)
93 {
95 }
96 lastRealTimeCandidate = counter;
97 }
98
99 internal void AdvanceFrameTime()
100 {
103 }
104
105 internal void Suspend()
106 {
107 suspendCount++;
108 if (suspendCount == 1)
109 {
111 }
112 }
113
114 internal void Resume()
115 {
116 suspendCount--;
117 if (suspendCount <= 0)
118 {
119 long counter = Counter;
122 }
123 }
124
125 private static TimeSpan CounterToTimeSpan(long delta)
126 {
127 long num = 10000000L;
128 long value = checked(delta * num) / Frequency;
129 return TimeSpan.FromTicks(value);
130 }
131}
static TimeSpan CounterToTimeSpan(long delta)
Definition GameClock.cs:125
static readonly long Frequency
Definition Stopwatch.cs:13
static readonly TimeSpan Zero
Definition TimeSpan.cs:21
static TimeSpan FromTicks(long value)
Definition TimeSpan.cs:277