First commit for private source control. Older commits available on Github.
This commit is contained in:
87
Assets/Scripts/Framework/Managers/Player/Data/Codex/Codex.cs
Normal file
87
Assets/Scripts/Framework/Managers/Player/Data/Codex/Codex.cs
Normal file
@@ -0,0 +1,87 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 15993ce7dcfd437186874d9d0822ad2d
|
||||
timeCreated: 1773682720
|
||||
@@ -0,0 +1,40 @@
|
||||
using BriarQueen.Framework.Managers.Levels.Data;
|
||||
using BriarQueen.Framework.Managers.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Managers.Player.Data.Codex
|
||||
{
|
||||
public class CodexTrigger : BaseItem, ICodexTrigger
|
||||
{
|
||||
[Header("Codex")]
|
||||
[SerializeField]
|
||||
private CodexEntrySo _codexEntry;
|
||||
|
||||
[SerializeField]
|
||||
private bool _removeTrigger;
|
||||
|
||||
public override UICursorService.CursorStyle ApplicableCursorStyle => UICursorService.CursorStyle.Inspect;
|
||||
|
||||
public override string InteractableName =>
|
||||
!string.IsNullOrWhiteSpace(InteractableTooltip) ? InteractableTooltip : _codexEntry.Title;
|
||||
|
||||
public GameObject TriggerObject => GameObject;
|
||||
public CodexEntrySo Entry => _codexEntry;
|
||||
|
||||
public bool RemoveTrigger => _removeTrigger;
|
||||
|
||||
public override async UniTask OnInteract(ItemDataSo item = null)
|
||||
{
|
||||
if (!CheckEmptyHands())
|
||||
return;
|
||||
|
||||
PlayerManager.UnlockCodexEntry(_codexEntry);
|
||||
|
||||
if (_removeTrigger)
|
||||
{
|
||||
await Remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7b26357202d94390a9d04c7cd3194b40
|
||||
timeCreated: 1773861326
|
||||
@@ -0,0 +1,13 @@
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Managers.Player.Data.Codex
|
||||
{
|
||||
public interface ICodexTrigger
|
||||
{
|
||||
GameObject TriggerObject { get; }
|
||||
|
||||
CodexEntrySo Entry { get; }
|
||||
bool RemoveTrigger { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2f81e1754251482a9e9bc183c5e1bd5b
|
||||
timeCreated: 1773868877
|
||||
Reference in New Issue
Block a user