-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathZone.cs
More file actions
46 lines (37 loc) · 1.41 KB
/
Zone.cs
File metadata and controls
46 lines (37 loc) · 1.41 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
using System.Collections.Generic;
using Gate.Networking;
namespace Gate
{
internal class Zone
{
private static readonly Dictionary<Client, Zone> clientToZoneMap_ = new Dictionary<Client, Zone>();
private Zone(int mapId, bool isExplorable)
{
MapId = mapId;
IsExplorable = isExplorable;
Clients = new List<Client>();
}
public int MapId { get; private set; }
public bool IsExplorable { get; private set; }
public List<Client> Clients { get; private set; }
public static Zone CreateInstance(int mapId)
{
return new Zone(mapId, false);
}
public static Zone FromClient(Client client)
{
Zone zone;
return clientToZoneMap_.TryGetValue(client, out zone) ? zone : null;
}
public void AddClient(Client client)
{
Clients.Add(client);
clientToZoneMap_.Add(client, this);
}
public void RemoveClient(Client client)
{
Clients.Remove(client);
clientToZoneMap_.Remove(client);
}
}
}