| | 1 | | using DCL; |
| | 2 | | using static Decentraland.Bff.AboutResponse.Types; |
| | 3 | |
|
| | 4 | | namespace DCLPlugins.RealmPlugin |
| | 5 | | { |
| | 6 | | /// <summary> |
| | 7 | | /// Toggles the state of the green blockers depending if the realm just entered is a world. |
| | 8 | | /// Also, it has a feature flag so we have the possibility to turn them off entirely. |
| | 9 | | /// </summary> |
| | 10 | | public class RealmBlockerModifier : IRealmModifier |
| | 11 | | { |
| | 12 | | private const int WORLD_BLOCKER_LIMIT = 2; |
| | 13 | | private const string ENABLE_GREEN_BLOCKERS_WORLDS_FF = "realms_blockers_in_worlds"; |
| | 14 | |
|
| | 15 | | private readonly BaseVariable<bool> worldBlockersEnabled; |
| | 16 | | private readonly BaseVariable<int> worldBlockersLimit; |
| | 17 | |
|
| 4 | 18 | | public RealmBlockerModifier(DataStore_WorldBlockers dataStoreWorldBlockers) |
| | 19 | | { |
| 4 | 20 | | worldBlockersEnabled = dataStoreWorldBlockers.worldBlockerEnabled; |
| 4 | 21 | | worldBlockersLimit = dataStoreWorldBlockers.worldBlockerLimit; |
| 4 | 22 | | } |
| | 23 | |
|
| 2 | 24 | | public void Dispose() { } |
| | 25 | |
|
| | 26 | | public void OnEnteredRealm(bool isWorld, AboutConfiguration realmConfiguration) |
| | 27 | | { |
| 6 | 28 | | bool shouldGreenBlockersBeActive = !isWorld || HasContentServers(realmConfiguration.CityLoaderContentServer) |
| | 29 | |
|
| | 30 | | bool HasContentServers(string cityLoaderContentServers) => |
| 3 | 31 | | !string.IsNullOrEmpty(cityLoaderContentServers); |
| | 32 | |
|
| 6 | 33 | | if (DataStore.i.featureFlags.flags.Get().IsFeatureEnabled(ENABLE_GREEN_BLOCKERS_WORLDS_FF)) |
| 0 | 34 | | worldBlockersLimit.Set(shouldGreenBlockersBeActive ? 0 : WORLD_BLOCKER_LIMIT); |
| | 35 | | else |
| 6 | 36 | | worldBlockersEnabled.Set(shouldGreenBlockersBeActive); |
| 6 | 37 | | } |
| | 38 | | } |
| | 39 | | } |