| | 1 | | using DCL; |
| | 2 | | using DCLPlugins.RealmsPlugin; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using Variables.RealmsInfo; |
| | 5 | | using static Decentraland.Bff.AboutResponse.Types; |
| | 6 | |
|
| | 7 | | namespace DCLPlugins.RealmPlugin |
| | 8 | | { |
| | 9 | | /// <summary> |
| | 10 | | /// Contains and triggers the realm modifiers when a new realm has been entered. This is triggered by setting a new |
| | 11 | | /// </summary> |
| | 12 | | public class RealmPlugin : IPlugin |
| | 13 | | { |
| | 14 | | private BaseVariable<AboutConfiguration> realmAboutConfiguration; |
| | 15 | | private List<RealmModel> currentCatalystRealmList; |
| | 16 | |
|
| | 17 | | internal List<IRealmModifier> realmsModifiers; |
| | 18 | |
|
| 2 | 19 | | public RealmPlugin(DataStore dataStore) |
| | 20 | | { |
| 2 | 21 | | this.realmsModifiers = new List<IRealmModifier> |
| | 22 | | { |
| | 23 | | new RealmBlockerModifier(dataStore.worldBlockers), |
| | 24 | | new RealmMinimapModifier(dataStore.HUDs), |
| | 25 | | new RealmsSkyboxModifier(dataStore.skyboxConfig), |
| | 26 | | new RealmsInfiniteFloorModifier(dataStore.HUDs) |
| | 27 | | }; |
| | 28 | |
|
| 2 | 29 | | realmAboutConfiguration = dataStore.realm.playerRealmAboutConfiguration; |
| 2 | 30 | | realmAboutConfiguration.OnChange += RealmChanged; |
| 2 | 31 | | } |
| | 32 | |
|
| | 33 | | public void Dispose() |
| | 34 | | { |
| 4 | 35 | | realmsModifiers.ForEach(rm => rm.Dispose()); |
| 2 | 36 | | realmAboutConfiguration.OnChange -= RealmChanged; |
| 2 | 37 | | } |
| | 38 | |
|
| | 39 | | private void RealmChanged(AboutConfiguration current, AboutConfiguration _) |
| | 40 | | { |
| 2 | 41 | | DataStore.i.common.isWorld.Set(current.IsWorld()); |
| 2 | 42 | | DataStore.i.realm.realmWasSetByFirstTime.Set(true); |
| | 43 | |
|
| 4 | 44 | | realmsModifiers.ForEach(rm => rm.OnEnteredRealm(current.IsWorld(), current)); |
| 2 | 45 | | } |
| | 46 | | } |
| | 47 | | } |