| | 1 | | using DCL.ServerTime; |
| | 2 | | using System; |
| | 3 | | using System.Collections.Generic; |
| | 4 | |
|
| | 5 | | namespace DCL |
| | 6 | | { |
| | 7 | | public enum AppMode |
| | 8 | | { |
| | 9 | | DEFAULT, |
| | 10 | | BUILDER_IN_WORLD_EDITION, |
| | 11 | | } |
| | 12 | |
|
| | 13 | | public class DataStore |
| | 14 | | { |
| 479900 | 15 | | public static DataStore i { get; private set; } = new (); |
| | 16 | |
|
| 1080 | 17 | | private readonly Dictionary<Type, object> dataStores = new (); |
| | 18 | |
|
| | 19 | | public void Set<T>(T data) where T: class |
| | 20 | | { |
| 8752 | 21 | | if (!dataStores.ContainsKey(typeof(T))) |
| 8751 | 22 | | dataStores.Add(typeof(T), data); |
| | 23 | | else |
| 1 | 24 | | dataStores[typeof(T)] = data; |
| 1 | 25 | | } |
| | 26 | |
|
| | 27 | | public T Get<T>() where T: class, new() |
| | 28 | | { |
| 245984 | 29 | | if (!dataStores.ContainsKey(typeof(T))) |
| 8751 | 30 | | Set(new T()); |
| | 31 | |
|
| 245984 | 32 | | return dataStores[typeof(T)] as T; |
| | 33 | | } |
| | 34 | |
|
| | 35 | | public static void Clear() => |
| 553 | 36 | | i = new DataStore(); |
| | 37 | |
|
| 167 | 38 | | public DataStore_World world => i.Get<DataStore_World>(); |
| 23387 | 39 | | public DataStore_Common common => i.Get<DataStore_Common>(); |
| 1691 | 40 | | public DataStore_Realm realm => i.Get<DataStore_Realm>(); |
| 2349 | 41 | | public DebugConfig debugConfig => i.Get<DebugConfig>(); |
| 54 | 42 | | public DataStore_Quests Quests => i.Get<DataStore_Quests>(); |
| 5099 | 43 | | public DataStore_HUDs HUDs => i.Get<DataStore_HUDs>(); |
| 5433 | 44 | | public DataStore_Player player => i.Get<DataStore_Player>(); |
| 35712 | 45 | | public DataStore_AvatarsLOD avatarsLOD => i.Get<DataStore_AvatarsLOD>(); |
| 3107 | 46 | | public DataStore_VirtualAudioMixer virtualAudioMixer => i.Get<DataStore_VirtualAudioMixer>(); |
| 46847 | 47 | | public DataStore_Screen screen => i.Get<DataStore_Screen>(); |
| 0 | 48 | | public DataStore_WSCommunication wsCommunication => i.Get<DataStore_WSCommunication>(); |
| 2768 | 49 | | public DataStore_WorldObjects sceneWorldObjects => i.Get<DataStore_WorldObjects>(); |
| 81779 | 50 | | public DataStore_ExploreV2 exploreV2 => i.Get<DataStore_ExploreV2>(); |
| 10245 | 51 | | public DataStore_FeatureFlag featureFlags => i.Get<DataStore_FeatureFlag>(); |
| 10298 | 52 | | public DataStore_Camera camera => i.Get<DataStore_Camera>(); |
| 662 | 53 | | public DataStore_Settings settings => i.Get<DataStore_Settings>(); |
| 69 | 54 | | public DataStore_SkyboxConfig skyboxConfig => i.Get<DataStore_SkyboxConfig>(); |
| 0 | 55 | | public WorldTimer worldTimer => i.Get<WorldTimer>(); |
| 741 | 56 | | public DataStore_Performance performance => i.Get<DataStore_Performance>(); |
| 128 | 57 | | public DataStore_ExperiencesViewer experiencesViewer => i.Get<DataStore_ExperiencesViewer>(); |
| 159 | 58 | | public DataStore_EmotesCustomization emotesCustomization => i.Get<DataStore_EmotesCustomization>(); |
| 215 | 59 | | public DataStore_SceneBoundariesChecker sceneBoundariesChecker => i.Get<DataStore_SceneBoundariesChecker>(); |
| 560 | 60 | | public DataStore_ECS7 ecs7 => i.Get<DataStore_ECS7>(); |
| 981 | 61 | | public DataStore_VoiceChat voiceChat => i.Get<DataStore_VoiceChat>(); |
| 279 | 62 | | public DataStore_TextureConfig textureConfig => i.Get<DataStore_TextureConfig>(); |
| 18 | 63 | | public DataStore_FriendNotifications friendNotifications => i.Get<DataStore_FriendNotifications>(); |
| 609 | 64 | | public DataStore_AvatarConfig avatarConfig => i.Get<DataStore_AvatarConfig>(); |
| 429 | 65 | | public DataStore_Rpc rpc => i.Get<DataStore_Rpc>(); |
| 333 | 66 | | public DataStore_Channels channels => i.Get<DataStore_Channels>(); |
| 876 | 67 | | public DataStore_WorldBlockers worldBlockers => i.Get<DataStore_WorldBlockers>(); |
| 7 | 68 | | public DataStore_Notifications notifications => i.Get<DataStore_Notifications>(); |
| 0 | 69 | | public DataStore_Outliner outliner => i.Get<DataStore_Outliner>(); |
| 170 | 70 | | public DataStore_Mentions mentions => i.Get<DataStore_Mentions>(); |
| 126 | 71 | | public DataStore_BackpackV2 backpackV2 => i.Get<DataStore_BackpackV2>(); |
| 551 | 72 | | public DataStore_Wallet wallet => i.Get<DataStore_Wallet>(); |
| 461 | 73 | | public DataStore_MyAccount myAccount => i.Get<DataStore_MyAccount>(); |
| 893 | 74 | | public DataStore_ContentModeration contentModeration => i.Get<DataStore_ContentModeration>(); |
| | 75 | | } |
| | 76 | |
|
| | 77 | | public struct DataStoreRef<T> where T: class, new() |
| | 78 | | { |
| | 79 | | private T @ref; |
| | 80 | |
|
| | 81 | | public T Ref => @ref ??= DataStore.i.Get<T>(); |
| | 82 | | } |
| | 83 | |
|
| | 84 | | } |
| | 85 | |
|
| | 86 | |
|
| | 87 | |
|