| | 1 | | using DCL.Helpers; |
| | 2 | | using UnityEngine; |
| | 3 | |
|
| | 4 | | public class MinimapMetadataController : MonoBehaviour |
| | 5 | | { |
| 105 | 6 | | private MinimapMetadata minimapMetadata => MinimapMetadata.GetMetadata(); |
| 0 | 7 | | public static MinimapMetadataController i { get; private set; } |
| | 8 | |
|
| | 9 | | public void Awake() |
| | 10 | | { |
| 105 | 11 | | i = this; |
| 105 | 12 | | minimapMetadata.Clear(); |
| 105 | 13 | | } |
| | 14 | |
|
| | 15 | | public void UpdateMinimapSceneInformation(string scenesInfoJson) |
| | 16 | | { |
| 0 | 17 | | var scenesInfo = Utils.ParseJsonArray<MinimapMetadata.MinimapSceneInfo[]>(scenesInfoJson); |
| | 18 | |
|
| 0 | 19 | | foreach (var sceneInfo in scenesInfo) |
| | 20 | | { |
| 0 | 21 | | minimapMetadata.AddSceneInfo(sceneInfo); |
| | 22 | | } |
| 0 | 23 | | } |
| | 24 | |
|
| | 25 | | /// <summary> |
| | 26 | | /// Updates the information of an user in the minimap. |
| | 27 | | /// </summary> |
| | 28 | | /// <param name="userInfo">User info model</param> |
| | 29 | | /// <param name="isRemoved">True for remove the user info</param> |
| | 30 | | public void UpdateMinimapUserInformation(MinimapMetadata.MinimapUserInfo userInfo, bool isRemoved = false) |
| | 31 | | { |
| 3 | 32 | | if (string.IsNullOrEmpty(userInfo.userId)) |
| 3 | 33 | | return; |
| | 34 | |
|
| 0 | 35 | | if (!isRemoved) |
| 0 | 36 | | minimapMetadata.AddOrUpdateUserInfo(userInfo); |
| | 37 | | else |
| 0 | 38 | | minimapMetadata.RemoveUserInfo(userInfo.userId); |
| 0 | 39 | | } |
| | 40 | | } |