forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIdFactory.cs
More file actions
40 lines (32 loc) · 1016 Bytes
/
Copy pathIdFactory.cs
File metadata and controls
40 lines (32 loc) · 1016 Bytes
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
using System.Linq;
using L2dotNET.Logging.Abstraction;
using L2dotNET.Services.Contracts;
namespace L2dotNET.Tables
{
public sealed class IdFactory : IInitialisable
{
private readonly IServerService _serverService;
private static readonly ILog Log = LogProvider.GetCurrentClassLogger();
public bool Initialised { get; private set; }
public const int IdMin = 0x10000000,
IdMax = 0x7FFFFFFF;
private int _currentId = 1;
public IdFactory(IServerService serverService)
{
_serverService = serverService;
}
public int NextId()
{
_currentId++;
return _currentId;
}
public void Initialise()
{
if (Initialised)
return;
_currentId = _serverService.GetPlayersItemsObjectIdList().DefaultIfEmpty(IdMin).Max();
Log.Info($"Used IDs {_currentId}.");
Initialised = true;
}
}
}