87 lines
2.1 KiB
C#
87 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using BriarQueen.Data.Identifiers;
|
|
using UnityEngine;
|
|
|
|
namespace BriarQueen.Framework.Managers.Player.Data.Codex
|
|
{
|
|
public class Codex
|
|
{
|
|
private readonly List<CodexEntrySo> _entries = new();
|
|
|
|
public IReadOnlyList<CodexEntrySo> Entries => _entries;
|
|
|
|
public void AddEntry(CodexEntrySo entry)
|
|
{
|
|
if (entry == null)
|
|
return;
|
|
|
|
if (_entries.Any(x => x.UniqueID == entry.UniqueID))
|
|
return;
|
|
|
|
Debug.Log($"Adding codex entry {entry.UniqueID}");
|
|
|
|
_entries.Add(entry);
|
|
}
|
|
|
|
public void RemoveEntry(CodexEntrySo entry)
|
|
{
|
|
if (entry == null)
|
|
return;
|
|
|
|
if (_entries.All(x => x.UniqueID != entry.UniqueID))
|
|
return;
|
|
|
|
_entries.Remove(entry);
|
|
}
|
|
|
|
public void RemoveEntry(string uniqueID)
|
|
{
|
|
var entry = _entries.FirstOrDefault(x => x.UniqueID == uniqueID);
|
|
|
|
if (entry)
|
|
_entries.Remove(entry);
|
|
}
|
|
|
|
public bool HasEntry(CodexEntrySo entry)
|
|
{
|
|
if (entry == null)
|
|
return false;
|
|
|
|
return _entries.Any(x => x.UniqueID == entry.UniqueID);
|
|
}
|
|
|
|
public bool HasEntry(string uniqueID)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(uniqueID))
|
|
return false;
|
|
|
|
return _entries.Any(x => x.UniqueID == uniqueID);
|
|
}
|
|
|
|
public IEnumerable<CodexEntrySo> GetEntriesByType(CodexType codexType)
|
|
{
|
|
return _entries.Where(x => x.EntryType == codexType);
|
|
}
|
|
|
|
public IEnumerable<CodexEntrySo> GetBookEntries()
|
|
{
|
|
return GetEntriesByType(CodexType.BookEntry);
|
|
}
|
|
|
|
public IEnumerable<CodexEntrySo> GetPuzzleClues()
|
|
{
|
|
return GetEntriesByType(CodexType.PuzzleClue);
|
|
}
|
|
|
|
public IEnumerable<CodexEntrySo> GetPhotoEntries()
|
|
{
|
|
return GetEntriesByType(CodexType.Photo);
|
|
}
|
|
|
|
public void ClearEntries()
|
|
{
|
|
_entries.Clear();
|
|
}
|
|
}
|
|
} |