First commit for private source control. Older commits available on Github.
This commit is contained in:
38
Assets/Scripts/Framework/Registries/AchievementRegistry.cs
Normal file
38
Assets/Scripts/Framework/Registries/AchievementRegistry.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BriarQueen.Data.Identifiers;
|
||||
using BriarQueen.Framework.Managers.Achievements.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Registries
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Briar Queen/Registries/New Achievement Registry", fileName = "Achievement Registry")]
|
||||
public class AchievementRegistry : ScriptableObject
|
||||
{
|
||||
[SerializeField]
|
||||
private List<AchievementSo> _achievementSos;
|
||||
|
||||
private Dictionary<AchievementID, AchievementSo> _achievementDictionary;
|
||||
|
||||
private void EnsureInitialized()
|
||||
{
|
||||
if (_achievementDictionary != null)
|
||||
return;
|
||||
|
||||
_achievementDictionary = _achievementSos.ToDictionary(achievement => achievement.Achievement,
|
||||
achievement => achievement);
|
||||
}
|
||||
|
||||
public bool TryGetAchievement(AchievementID identifier, out AchievementSo achievement)
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _achievementDictionary.TryGetValue(identifier, out achievement);
|
||||
}
|
||||
|
||||
public IEnumerable<AchievementSo> GetAchievements()
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _achievementDictionary.Values;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75861bb06f754b33afae416568d5f74d
|
||||
timeCreated: 1772721470
|
||||
119
Assets/Scripts/Framework/Registries/AssetRegistry.cs
Normal file
119
Assets/Scripts/Framework/Registries/AssetRegistry.cs
Normal file
@@ -0,0 +1,119 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Data.Assets;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AddressableAssets;
|
||||
|
||||
namespace BriarQueen.Framework.Registries
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Briar Queen/Registries/Asset Registry", fileName = "New Asset Registry")]
|
||||
public class AssetRegistry : ScriptableObject
|
||||
{
|
||||
[Header("Asset References (Generic Addressables)")]
|
||||
[ReorderableList]
|
||||
[SerializeField]
|
||||
private List<AssetEntry> _sceneReferences = new();
|
||||
|
||||
[ReorderableList]
|
||||
[SerializeField]
|
||||
private List<AssetEntry> _levelReferences = new();
|
||||
|
||||
[ReorderableList]
|
||||
[SerializeField]
|
||||
private List<AssetEntry> _itemReferences = new();
|
||||
|
||||
[ReorderableList]
|
||||
[SerializeField]
|
||||
private List<AssetEntry> _uiReferences = new();
|
||||
|
||||
private Dictionary<string, AssetReference> _assetDictionary;
|
||||
|
||||
public IReadOnlyList<AssetEntry> SceneReferences => _sceneReferences;
|
||||
public IReadOnlyList<AssetEntry> LevelReferences => _levelReferences;
|
||||
public IReadOnlyList<AssetEntry> ItemReferences => _itemReferences;
|
||||
public IReadOnlyList<AssetEntry> UIReferences => _uiReferences;
|
||||
|
||||
public void EnsureInitialized()
|
||||
{
|
||||
if (_assetDictionary != null)
|
||||
return;
|
||||
|
||||
RebuildLookup();
|
||||
}
|
||||
|
||||
public void RebuildLookup()
|
||||
{
|
||||
_assetDictionary = new Dictionary<string, AssetReference>();
|
||||
|
||||
AddEntries(_sceneReferences, "Scenes");
|
||||
AddEntries(_levelReferences, "Levels");
|
||||
AddEntries(_itemReferences, "Items");
|
||||
AddEntries(_uiReferences, "UI");
|
||||
}
|
||||
|
||||
private void AddEntries(List<AssetEntry> entries, string category)
|
||||
{
|
||||
if (entries == null)
|
||||
return;
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entry.AssetKey))
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"[AssetRegistry] Skipping {category} entry '{entry.name}' because AssetKey is empty.", this);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.Asset == null)
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"[AssetRegistry] Skipping {category} entry '{entry.name}' because AssetReference is null.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_assetDictionary.ContainsKey(entry.AssetKey))
|
||||
{
|
||||
Debug.LogError(
|
||||
$"[AssetRegistry] Duplicate AssetKey detected: '{entry.AssetKey}' from entry '{entry.name}'.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
_assetDictionary.Add(entry.AssetKey, entry.Asset);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetReference(string key, out AssetReference reference)
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _assetDictionary.TryGetValue(key, out reference);
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllKeys()
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _assetDictionary.Keys;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void SetDiscoveredEntries(
|
||||
List<AssetEntry> sceneEntries,
|
||||
List<AssetEntry> levelEntries,
|
||||
List<AssetEntry> itemEntries,
|
||||
List<AssetEntry> uiEntries)
|
||||
{
|
||||
_sceneReferences = sceneEntries ?? new List<AssetEntry>();
|
||||
_levelReferences = levelEntries ?? new List<AssetEntry>();
|
||||
_itemReferences = itemEntries ?? new List<AssetEntry>();
|
||||
_uiReferences = uiEntries ?? new List<AssetEntry>();
|
||||
|
||||
RebuildLookup();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 631abf866da44455b63000376e0daf7c
|
||||
timeCreated: 1769711034
|
||||
31
Assets/Scripts/Framework/Registries/AudioRegistry.cs
Normal file
31
Assets/Scripts/Framework/Registries/AudioRegistry.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using BriarQueen.Framework.Managers.Audio.Data;
|
||||
using NaughtyAttributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Registries
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Briar Queen/Registries/New Audio Registry", fileName = "New Audio Registry")]
|
||||
public class AudioRegistry : ScriptableObject
|
||||
{
|
||||
[ReorderableList]
|
||||
[SerializeField]
|
||||
private List<AudioFileSo> _audioFiles;
|
||||
|
||||
private Dictionary<string, AudioFileSo> _audioFileDict;
|
||||
|
||||
private void EnsureInitialized()
|
||||
{
|
||||
if (_audioFileDict == null)
|
||||
_audioFileDict = _audioFiles.ToDictionary(entry => entry.UniqueID, entry => entry);
|
||||
}
|
||||
|
||||
public bool TryGetAudio(string audioName, out AudioFileSo audioFile)
|
||||
{
|
||||
if (_audioFileDict == null) EnsureInitialized();
|
||||
|
||||
return _audioFileDict!.TryGetValue(audioName, out audioFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62dff6444b30424c970fce22db449226
|
||||
timeCreated: 1769802179
|
||||
133
Assets/Scripts/Framework/Registries/CodexRegistry.cs
Normal file
133
Assets/Scripts/Framework/Registries/CodexRegistry.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Registries
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Briar Queen/Registries/Codex Registry", fileName = "Codex Registry")]
|
||||
public class CodexRegistry : ScriptableObject
|
||||
{
|
||||
[Header("Codex Entries")]
|
||||
[SerializeField]
|
||||
private List<CodexEntrySo> _bookEntries = new();
|
||||
|
||||
[SerializeField]
|
||||
private List<CodexEntrySo> _puzzleClues = new();
|
||||
|
||||
[SerializeField]
|
||||
private List<CodexEntrySo> _photoEntries = new();
|
||||
|
||||
private Dictionary<string, CodexEntrySo> _entryLookup;
|
||||
|
||||
public IReadOnlyList<CodexEntrySo> BookEntries => _bookEntries;
|
||||
public IReadOnlyList<CodexEntrySo> PuzzleClues => _puzzleClues;
|
||||
public IReadOnlyList<CodexEntrySo> PhotoEntries => _photoEntries;
|
||||
|
||||
public void EnsureInitialized()
|
||||
{
|
||||
if (_entryLookup != null)
|
||||
return;
|
||||
|
||||
RebuildLookup();
|
||||
}
|
||||
|
||||
public void RebuildLookup()
|
||||
{
|
||||
_entryLookup = new Dictionary<string, CodexEntrySo>();
|
||||
|
||||
AddEntries(_bookEntries, "Book Entries");
|
||||
AddEntries(_puzzleClues, "Puzzle Clues");
|
||||
AddEntries(_photoEntries, "Photo Entries");
|
||||
}
|
||||
|
||||
private void AddEntries(List<CodexEntrySo> entries, string category)
|
||||
{
|
||||
if (entries == null)
|
||||
return;
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entry.UniqueID))
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"[CodexRegistry] Skipping {category} entry '{entry.name}' because UniqueID is empty.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_entryLookup.ContainsKey(entry.UniqueID))
|
||||
{
|
||||
Debug.LogError(
|
||||
$"[CodexRegistry] Duplicate UniqueID detected: '{entry.UniqueID}' from entry '{entry.name}'.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
_entryLookup.Add(entry.UniqueID, entry);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetEntry(string entryID, out CodexEntrySo entry)
|
||||
{
|
||||
EnsureInitialized();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entryID))
|
||||
{
|
||||
entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return _entryLookup.TryGetValue(entryID, out entry);
|
||||
}
|
||||
|
||||
public CodexEntrySo FindEntryByID(string entryID)
|
||||
{
|
||||
EnsureInitialized();
|
||||
return string.IsNullOrWhiteSpace(entryID) ? null : _entryLookup.GetValueOrDefault(entryID);
|
||||
}
|
||||
|
||||
public IEnumerable<CodexEntrySo> GetAllEntries()
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _entryLookup.Values;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllKeys()
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _entryLookup.Keys;
|
||||
}
|
||||
|
||||
public IEnumerable<CodexEntrySo> GetBookEntries()
|
||||
{
|
||||
return _bookEntries;
|
||||
}
|
||||
|
||||
public IEnumerable<CodexEntrySo> GetPuzzleClues()
|
||||
{
|
||||
return _puzzleClues;
|
||||
}
|
||||
|
||||
public IEnumerable<CodexEntrySo> GetPhotoEntries()
|
||||
{
|
||||
return _photoEntries;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void SetDiscoveredEntries(
|
||||
List<CodexEntrySo> bookEntries,
|
||||
List<CodexEntrySo> puzzleClues,
|
||||
List<CodexEntrySo> photoEntries)
|
||||
{
|
||||
_bookEntries = bookEntries ?? new List<CodexEntrySo>();
|
||||
_puzzleClues = puzzleClues ?? new List<CodexEntrySo>();
|
||||
_photoEntries = photoEntries ?? new List<CodexEntrySo>();
|
||||
|
||||
RebuildLookup();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 77f19a36607b40e59260f8cccdde53c2
|
||||
timeCreated: 1773682356
|
||||
133
Assets/Scripts/Framework/Registries/ItemRegistry.cs
Normal file
133
Assets/Scripts/Framework/Registries/ItemRegistry.cs
Normal file
@@ -0,0 +1,133 @@
|
||||
using System.Collections.Generic;
|
||||
using BriarQueen.Framework.Managers.Player.Data;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BriarQueen.Framework.Registries
|
||||
{
|
||||
[CreateAssetMenu(menuName = "Briar Queen/Registries/Item Registry", fileName = "New Item Registry")]
|
||||
public class ItemRegistry : ScriptableObject
|
||||
{
|
||||
[Header("Items")]
|
||||
[SerializeField]
|
||||
private List<ItemDataSo> _puzzleSlots = new();
|
||||
|
||||
[SerializeField]
|
||||
private List<ItemDataSo> _pickupItems = new();
|
||||
|
||||
[SerializeField]
|
||||
private List<ItemDataSo> _environmentInteractables = new();
|
||||
|
||||
private Dictionary<string, ItemDataSo> _entryLookup;
|
||||
|
||||
public IReadOnlyList<ItemDataSo> PuzzleSlots => _puzzleSlots;
|
||||
public IReadOnlyList<ItemDataSo> PickupItems => _pickupItems;
|
||||
public IReadOnlyList<ItemDataSo> EnvironmentInteractables => _environmentInteractables;
|
||||
|
||||
public void EnsureInitialized()
|
||||
{
|
||||
if (_entryLookup != null)
|
||||
return;
|
||||
|
||||
RebuildLookup();
|
||||
}
|
||||
|
||||
public void RebuildLookup()
|
||||
{
|
||||
_entryLookup = new Dictionary<string, ItemDataSo>();
|
||||
|
||||
AddEntries(_puzzleSlots, "Puzzle Slots");
|
||||
AddEntries(_pickupItems, "Pickup Items");
|
||||
AddEntries(_environmentInteractables, "Environment Interactables");
|
||||
}
|
||||
|
||||
private void AddEntries(List<ItemDataSo> entries, string category)
|
||||
{
|
||||
if (entries == null)
|
||||
return;
|
||||
|
||||
foreach (var entry in entries)
|
||||
{
|
||||
if (entry == null)
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(entry.UniqueID))
|
||||
{
|
||||
Debug.LogWarning(
|
||||
$"[ItemRegistry] Skipping {category} entry '{entry.name}' because UniqueID is empty.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_entryLookup.ContainsKey(entry.UniqueID))
|
||||
{
|
||||
Debug.LogError(
|
||||
$"[ItemRegistry] Duplicate UniqueID detected: '{entry.UniqueID}' from entry '{entry.name}'.",
|
||||
this);
|
||||
continue;
|
||||
}
|
||||
|
||||
_entryLookup.Add(entry.UniqueID, entry);
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryGetEntry(string itemID, out ItemDataSo entry)
|
||||
{
|
||||
EnsureInitialized();
|
||||
|
||||
if (string.IsNullOrWhiteSpace(itemID))
|
||||
{
|
||||
entry = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
return _entryLookup.TryGetValue(itemID, out entry);
|
||||
}
|
||||
|
||||
public ItemDataSo FindItemTemplateByID(string itemID)
|
||||
{
|
||||
EnsureInitialized();
|
||||
return string.IsNullOrWhiteSpace(itemID) ? null : _entryLookup.GetValueOrDefault(itemID);
|
||||
}
|
||||
|
||||
public IEnumerable<ItemDataSo> GetAllItems()
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _entryLookup.Values;
|
||||
}
|
||||
|
||||
public IEnumerable<string> GetAllKeys()
|
||||
{
|
||||
EnsureInitialized();
|
||||
return _entryLookup.Keys;
|
||||
}
|
||||
|
||||
public IEnumerable<ItemDataSo> GetPuzzleSlots()
|
||||
{
|
||||
return _puzzleSlots;
|
||||
}
|
||||
|
||||
public IEnumerable<ItemDataSo> GetPickupItems()
|
||||
{
|
||||
return _pickupItems;
|
||||
}
|
||||
|
||||
public IEnumerable<ItemDataSo> GetEnvironmentInteractables()
|
||||
{
|
||||
return _environmentInteractables;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public void SetDiscoveredEntries(
|
||||
List<ItemDataSo> puzzleSlots,
|
||||
List<ItemDataSo> pickupItems,
|
||||
List<ItemDataSo> environmentInteractables)
|
||||
{
|
||||
_puzzleSlots = puzzleSlots ?? new List<ItemDataSo>();
|
||||
_pickupItems = pickupItems ?? new List<ItemDataSo>();
|
||||
_environmentInteractables = environmentInteractables ?? new List<ItemDataSo>();
|
||||
|
||||
RebuildLookup();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
3
Assets/Scripts/Framework/Registries/ItemRegistry.cs.meta
Normal file
3
Assets/Scripts/Framework/Registries/ItemRegistry.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3b4747374c1049f8917c5ceb4bc8a1b0
|
||||
timeCreated: 1769703999
|
||||
Reference in New Issue
Block a user