-
Notifications
You must be signed in to change notification settings - Fork 1
/
OnlineId.cs
69 lines (58 loc) · 1.35 KB
/
OnlineId.cs
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using Cardamom.Serialization;
namespace PanzerBlitz
{
public struct OnlineId : Serializable
{
public static OnlineId Permanent(long Id)
{
return new OnlineId(Id, false);
}
public static OnlineId Temporary(long Id)
{
return new OnlineId(Id, true);
}
public long Id { get; }
public bool IsTemporary { get; }
OnlineId(long Id, bool IsTemporary)
{
this.Id = Id;
this.IsTemporary = IsTemporary;
}
public OnlineId(SerializationInputStream Stream)
{
Id = Stream.ReadInt64();
IsTemporary = Stream.ReadBoolean();
}
public void Serialize(SerializationOutputStream Stream)
{
Stream.Write(Id);
Stream.Write(IsTemporary);
}
public override bool Equals(object obj)
{
if (obj == null) return false;
if (obj is OnlineId)
{
var o = (OnlineId)obj;
return Id == o.Id && IsTemporary == o.IsTemporary;
}
return false;
}
public override int GetHashCode()
{
return Id.GetHashCode() ^ IsTemporary.GetHashCode();
}
public static bool operator ==(OnlineId i1, OnlineId i2)
{
return i1.Equals(i2);
}
public static bool operator !=(OnlineId i1, OnlineId i2)
{
return !(i1 == i2);
}
public override string ToString()
{
return string.Format("[OnlineId: Id={0}, IsTemporary={1}]", Id, IsTemporary);
}
}
}