forked from hunterzonewu/unity-decompiled
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConnectionArray.cs
More file actions
134 lines (121 loc) · 3.83 KB
/
ConnectionArray.cs
File metadata and controls
134 lines (121 loc) · 3.83 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Decompiled with JetBrains decompiler
// Type: UnityEngine.Networking.ConnectionArray
// Assembly: UnityEngine.Networking, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: 8B34E19C-EF53-416E-AE36-35C45BAFD2DE
// Assembly location: C:\Users\Blake\sandbox\unity\test-project\Library\UnityAssemblies\UnityEngine.Networking.dll
using System.Collections.Generic;
namespace UnityEngine.Networking
{
internal class ConnectionArray
{
private List<NetworkConnection> m_LocalConnections;
private List<NetworkConnection> m_Connections;
internal List<NetworkConnection> localConnections
{
get
{
return this.m_LocalConnections;
}
}
internal List<NetworkConnection> connections
{
get
{
return this.m_Connections;
}
}
public int Count
{
get
{
return this.m_Connections.Count;
}
}
public int LocalIndex
{
get
{
return -this.m_LocalConnections.Count;
}
}
public ConnectionArray()
{
this.m_Connections = new List<NetworkConnection>();
this.m_LocalConnections = new List<NetworkConnection>();
}
public int Add(int connId, NetworkConnection conn)
{
if (connId < 0)
{
if (LogFilter.logWarn)
Debug.LogWarning((object) ("ConnectionArray Add bad id " + (object) connId));
return -1;
}
if (connId < this.m_Connections.Count && this.m_Connections[connId] != null)
{
if (LogFilter.logWarn)
Debug.LogWarning((object) ("ConnectionArray Add dupe at " + (object) connId));
return -1;
}
while (connId > this.m_Connections.Count - 1)
this.m_Connections.Add((NetworkConnection) null);
this.m_Connections[connId] = conn;
return connId;
}
public NetworkConnection Get(int connId)
{
if (connId < 0)
return this.m_LocalConnections[Mathf.Abs(connId) - 1];
if (connId >= 0 && connId <= this.m_Connections.Count)
return this.m_Connections[connId];
if (LogFilter.logWarn)
Debug.LogWarning((object) ("ConnectionArray Get invalid index " + (object) connId));
return (NetworkConnection) null;
}
public NetworkConnection GetUnsafe(int connId)
{
if (connId < 0 || connId > this.m_Connections.Count)
return (NetworkConnection) null;
return this.m_Connections[connId];
}
public void Remove(int connId)
{
if (connId < 0)
this.m_LocalConnections[Mathf.Abs(connId) - 1] = (NetworkConnection) null;
else if (connId < 0 || connId > this.m_Connections.Count)
{
if (!LogFilter.logWarn)
return;
Debug.LogWarning((object) ("ConnectionArray Remove invalid index " + (object) connId));
}
else
this.m_Connections[connId] = (NetworkConnection) null;
}
public int AddLocal(NetworkConnection conn)
{
this.m_LocalConnections.Add(conn);
int num = -this.m_LocalConnections.Count;
conn.connectionId = num;
return num;
}
public bool ContainsPlayer(GameObject player, out NetworkConnection conn)
{
conn = (NetworkConnection) null;
if ((Object) player == (Object) null)
return false;
for (int localIndex = this.LocalIndex; localIndex < this.m_Connections.Count; ++localIndex)
{
conn = this.Get(localIndex);
if (conn != null)
{
for (int index = 0; index < conn.playerControllers.Count; ++index)
{
if (conn.playerControllers[index].IsValid && (Object) conn.playerControllers[index].gameObject == (Object) player)
return true;
}
}
}
return false;
}
}
}