forked from FabianTerhorst/coreclr-module
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDataSnapshot.cs
More file actions
50 lines (43 loc) · 1.13 KB
/
DataSnapshot.cs
File metadata and controls
50 lines (43 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections.Generic;
namespace AltV.Net.EntitySync
{
/// <summary>
/// Saves the state of the entity data and player received data
/// </summary>
public class DataSnapshot
{
// snapshot versions for each data key
public readonly IDictionary<string, ulong> Snapshots;
public DataSnapshot()
{
Snapshots = new Dictionary<string, ulong>();
}
public DataSnapshot(IDictionary<string, ulong> snapshots)
{
Snapshots = snapshots;
}
public void Update(string key)
{
if (Snapshots.TryGetValue(key, out var currSnapshot))
{
if (currSnapshot == 0)
{
OnOverflow(key);
currSnapshot = 1;
}
Snapshots[key] = currSnapshot + 1;
}
else
{
Snapshots[key] = 1;
}
}
public void Reset(string key)
{
Snapshots[key] = 0;
}
public virtual void OnOverflow(string key)
{
}
}
}