| | 1 | | using DCL.Social.Chat; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using System.Linq; |
| | 5 | | using UnityEngine; |
| | 6 | |
|
| | 7 | | namespace DCL.Social.Chat |
| | 8 | | { |
| | 9 | | [CreateAssetMenu(fileName = "ChannelEntryFactory", menuName = "DCL/Social/ChannelEntryFactory")] |
| | 10 | | public class ChannelEntryFactory : ScriptableObject |
| | 11 | | { |
| | 12 | | [Serializable] |
| | 13 | | private struct SpecialEntry |
| | 14 | | { |
| | 15 | | public string channelId; |
| | 16 | | public PublicChatEntry prefab; |
| | 17 | | } |
| | 18 | |
|
| | 19 | | [SerializeField] private PublicChatEntry defaultEntryPrefab; |
| | 20 | | [SerializeField] private SpecialEntry[] specialEntryPrefabs; |
| | 21 | |
|
| | 22 | | private Dictionary<string, PublicChatEntry> specialEntries; |
| | 23 | |
|
| | 24 | | public PublicChatEntry Create(string channelId) |
| | 25 | | { |
| 36 | 26 | | specialEntries ??= specialEntryPrefabs.ToDictionary(entry => entry.channelId, entry => entry.prefab); |
| 32 | 27 | | return Instantiate(specialEntries.ContainsKey(channelId) ? specialEntries[channelId] : defaultEntryPrefab); |
| | 28 | | } |
| | 29 | | } |
| | 30 | | } |