PalacePal/Pal.Client/Floors/MemoryTerritory.cs

64 lines
1.7 KiB
C#
Raw Normal View History

2023-02-18 20:12:36 +00:00
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using Pal.Client.Configuration;
using Pal.Client.Scheduled;
2023-02-18 20:12:36 +00:00
using Pal.Common;
namespace Pal.Client.Floors
{
/// <summary>
/// A single set of floors loaded entirely in memory, can be e.g. POTD 51-60.
/// </summary>
internal sealed class MemoryTerritory
{
public MemoryTerritory(ETerritoryType territoryType)
{
TerritoryType = territoryType;
}
public ETerritoryType TerritoryType { get; }
2023-02-22 19:29:58 +00:00
public EReadyState ReadyState { get; set; } = EReadyState.NotLoaded;
public ESyncState SyncState { get; set; } = ESyncState.NotAttempted;
2023-02-18 20:12:36 +00:00
public ConcurrentBag<PersistentLocation> Locations { get; } = new();
public object LockObj { get; } = new();
public void Initialize(IEnumerable<PersistentLocation> locations)
{
Locations.Clear();
foreach (var location in locations)
Locations.Add(location);
2023-02-22 19:29:58 +00:00
ReadyState = EReadyState.Ready;
2023-02-18 20:12:36 +00:00
}
2023-02-22 19:29:58 +00:00
public void Reset()
2023-02-18 20:12:36 +00:00
{
2023-02-22 19:29:58 +00:00
Locations.Clear();
SyncState = ESyncState.NotAttempted;
ReadyState = EReadyState.NotLoaded;
2023-02-18 20:12:36 +00:00
}
2023-02-22 19:29:58 +00:00
public enum EReadyState
2023-02-18 20:12:36 +00:00
{
2023-02-22 19:29:58 +00:00
NotLoaded,
/// <summary>
/// Currently loading from the database.
/// </summary>
Loading,
/// <summary>
/// Locations loaded, no import running.
/// </summary>
Ready,
/// <summary>
/// Import running, should probably not interact with this too much.
/// </summary>
Importing,
2023-02-18 20:12:36 +00:00
}
}
}