| | 1 | | using System.Collections; |
| | 2 | | using System.Collections.Generic; |
| | 3 | | using DCL; |
| | 4 | | using DCLPlugins.RealmPlugin; |
| | 5 | | using Decentraland.Bff; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | namespace DCLPlugins.RealmsPlugin |
| | 9 | | { |
| | 10 | | public class RealmsInfiniteFloorModifier : IRealmModifier |
| | 11 | | { |
| | 12 | | private BaseVariable<Texture> mapMainTexture; |
| | 13 | | private BaseVariable<Texture> mapEstatesTexture; |
| | 14 | |
|
| | 15 | | private BaseVariable<Texture> latestMapMainTexture; |
| | 16 | | private BaseVariable<Texture> latestEstatesMainTexture; |
| | 17 | |
|
| | 18 | | private bool currentlyInWorld; |
| | 19 | |
|
| 5 | 20 | | public RealmsInfiniteFloorModifier(DataStore_HUDs hudsDataStore) |
| | 21 | | { |
| 5 | 22 | | this.mapMainTexture = hudsDataStore.mapMainTexture; |
| 5 | 23 | | this.mapEstatesTexture = hudsDataStore.mapEstatesTexture; |
| 5 | 24 | | this.latestMapMainTexture = hudsDataStore.latestDownloadedMainTexture; |
| 5 | 25 | | this.latestEstatesMainTexture = hudsDataStore.latestDownloadedMapEstatesTexture; |
| | 26 | |
|
| 5 | 27 | | latestMapMainTexture.OnChange += UpdateMapMainTexture; |
| 5 | 28 | | latestEstatesMainTexture.OnChange += UpdateEstatesMainTexture; |
| 5 | 29 | | } |
| | 30 | |
|
| | 31 | | private void UpdateEstatesMainTexture(Texture current, Texture _) |
| | 32 | | { |
| 5 | 33 | | if (currentlyInWorld) return; |
| 3 | 34 | | mapEstatesTexture.Set(current); |
| 3 | 35 | | } |
| | 36 | |
|
| | 37 | | private void UpdateMapMainTexture(Texture current, Texture _) |
| | 38 | | { |
| 5 | 39 | | if (currentlyInWorld) return; |
| 3 | 40 | | mapMainTexture.Set(current); |
| 3 | 41 | | } |
| | 42 | |
|
| | 43 | | public void OnEnteredRealm(bool isWorld, AboutResponse.Types.AboutConfiguration realmConfiguration) |
| | 44 | | { |
| 4 | 45 | | currentlyInWorld = isWorld; |
| 4 | 46 | | if (isWorld) |
| | 47 | | { |
| | 48 | | //TODO: We can offer the possibility to add an infinite world layout per world. For now, |
| | 49 | | // we nullify and show the orange plaza color |
| 2 | 50 | | mapMainTexture.Set(null); |
| 2 | 51 | | mapEstatesTexture.Set(null); |
| | 52 | | } |
| | 53 | | else |
| | 54 | | { |
| 2 | 55 | | mapMainTexture.Set(latestMapMainTexture.Get()); |
| 2 | 56 | | mapEstatesTexture.Set(latestEstatesMainTexture.Get()); |
| | 57 | | } |
| 2 | 58 | | } |
| | 59 | |
|
| | 60 | | public void Dispose() |
| | 61 | | { |
| 3 | 62 | | latestMapMainTexture.OnChange -= UpdateMapMainTexture; |
| 3 | 63 | | latestEstatesMainTexture.OnChange -= UpdateEstatesMainTexture; |
| 3 | 64 | | } |
| | 65 | | } |
| | 66 | | } |