-
Notifications
You must be signed in to change notification settings - Fork 16
/
CurrentMapStateRepository.cs
117 lines (74 loc) · 3.3 KB
/
CurrentMapStateRepository.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
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
using System.Collections.Generic;
using AutomaticTypeMapper;
using EOLib.Domain.Character;
using EOLib.Domain.NPC;
namespace EOLib.Domain.Map
{
public interface ICurrentMapStateRepository
{
short CurrentMapID { get; set; }
bool ShowMiniMap { get; set; }
Dictionary<int, ICharacter> Characters { get; set; }
HashSet<INPC> NPCs { get; set; }
HashSet<IItem> MapItems { get; set; }
HashSet<IWarp> OpenDoors { get; set; }
HashSet<IWarp> PendingDoors { get; set; }
HashSet<MapCoordinate> VisibleSpikeTraps { get; set; }
WarpState MapWarpState { get; set; }
HashSet<short> UnknownPlayerIDs { get; set; }
HashSet<byte> UnknownNPCIndexes { get; set; }
}
public interface ICurrentMapStateProvider
{
short CurrentMapID { get; }
bool ShowMiniMap { get; }
IReadOnlyDictionary<int, ICharacter> Characters { get; }
IReadOnlyCollection<INPC> NPCs { get; }
IReadOnlyCollection<IItem> MapItems { get; }
IReadOnlyCollection<IWarp> OpenDoors { get; }
IReadOnlyCollection<IWarp> PendingDoors { get; }
IReadOnlyCollection<MapCoordinate> VisibleSpikeTraps { get; }
WarpState MapWarpState { get; }
HashSet<short> UnknownPlayerIDs { get; }
HashSet<byte> UnknownNPCIndexes { get; }
}
[AutoMappedType(IsSingleton = true)]
public class CurrentMapStateRepository : ICurrentMapStateRepository, ICurrentMapStateProvider, IResettable
{
public short CurrentMapID { get; set; }
public bool ShowMiniMap { get; set; }
public Dictionary<int, ICharacter> Characters { get; set; }
public HashSet<INPC> NPCs { get; set; }
public HashSet<IItem> MapItems { get; set; }
public HashSet<IWarp> OpenDoors { get; set; }
public HashSet<IWarp> PendingDoors { get; set; }
public HashSet<MapCoordinate> VisibleSpikeTraps { get; set; }
public WarpState MapWarpState { get; set; }
public HashSet<short> UnknownPlayerIDs { get; set; }
public HashSet<byte> UnknownNPCIndexes { get; set; }
IReadOnlyDictionary<int, ICharacter> ICurrentMapStateProvider.Characters => Characters;
IReadOnlyCollection<INPC> ICurrentMapStateProvider.NPCs => NPCs;
IReadOnlyCollection<IItem> ICurrentMapStateProvider.MapItems => MapItems;
IReadOnlyCollection<IWarp> ICurrentMapStateProvider.OpenDoors => OpenDoors;
IReadOnlyCollection<IWarp> ICurrentMapStateProvider.PendingDoors => PendingDoors;
IReadOnlyCollection<MapCoordinate> ICurrentMapStateProvider.VisibleSpikeTraps => VisibleSpikeTraps;
public CurrentMapStateRepository()
{
ResetState();
}
public void ResetState()
{
CurrentMapID = 0;
ShowMiniMap = false;
Characters = new Dictionary<int, ICharacter>();
NPCs = new HashSet<INPC>();
MapItems = new HashSet<IItem>();
OpenDoors = new HashSet<IWarp>();
PendingDoors = new HashSet<IWarp>();
VisibleSpikeTraps = new HashSet<MapCoordinate>();
UnknownPlayerIDs = new HashSet<short>();
UnknownNPCIndexes = new HashSet<byte>();
MapWarpState = WarpState.None;
}
}
}