| | 1 | | using Cysharp.Threading.Tasks; |
| | 2 | | using DCL; |
| | 3 | | using JetBrains.Annotations; |
| | 4 | | using System; |
| | 5 | | using System.Threading; |
| | 6 | | using UnityEngine; |
| | 7 | |
|
| | 8 | | public class HUDBridge : MonoBehaviour |
| | 9 | | { |
| | 10 | | private CancellationTokenSource cancellationTokenSource; |
| | 11 | |
|
| | 12 | | private void Awake() |
| | 13 | | { |
| 0 | 14 | | cancellationTokenSource = new CancellationTokenSource(); |
| 0 | 15 | | } |
| | 16 | |
|
| | 17 | | private void OnDestroy() |
| | 18 | | { |
| 0 | 19 | | cancellationTokenSource.Cancel(); |
| 0 | 20 | | cancellationTokenSource.Dispose(); |
| 0 | 21 | | } |
| | 22 | |
|
| | 23 | | #region MessagesFromKernel |
| | 24 | |
|
| | 25 | | [System.Serializable] |
| | 26 | | class ConfigureHUDElementMessage |
| | 27 | | { |
| | 28 | | public HUDElementID hudElementId; |
| | 29 | | public HUDConfiguration configuration; |
| | 30 | | public string extraPayload; |
| | 31 | | } |
| | 32 | |
|
| | 33 | | [UsedImplicitly] |
| | 34 | | public void ConfigureHUDElement(string payload) |
| | 35 | | { |
| 0 | 36 | | ConfigureHUDElementMessage message = JsonUtility.FromJson<ConfigureHUDElementMessage>(payload); |
| | 37 | |
|
| 0 | 38 | | HUDElementID id = message.hudElementId; |
| 0 | 39 | | HUDConfiguration configuration = message.configuration; |
| 0 | 40 | | string extraPayload = message.extraPayload; |
| | 41 | |
|
| 0 | 42 | | HUDController.i.ConfigureHUDElement(id, configuration, cancellationTokenSource.Token, extraPayload).Forget(); |
| 0 | 43 | | } |
| | 44 | |
|
| 0 | 45 | | public void TriggerSelfUserExpression(string id) { UserProfile.GetOwnUserProfile().SetAvatarExpression(id, UserProfi |
| | 46 | |
|
| | 47 | | public void ShowTermsOfServices(string payload) |
| | 48 | | { |
| 0 | 49 | | var model = JsonUtility.FromJson<TermsOfServiceHUDController.Model>(payload); |
| 0 | 50 | | HUDController.i.termsOfServiceHud?.ShowTermsOfService(model); |
| 0 | 51 | | } |
| | 52 | |
|
| 0 | 53 | | public void SetPlayerTalking(string talking) { HUDController.i.voiceChatHud?.SetVoiceChatRecording("true".Equals(tal |
| | 54 | |
|
| | 55 | | public void SetVoiceChatEnabledByScene(int enabledPayload) |
| | 56 | | { |
| 0 | 57 | | bool isEnabled = enabledPayload != 0; |
| 0 | 58 | | HUDController.i.voiceChatHud?.SetVoiceChatEnabledByScene(isEnabled); |
| 0 | 59 | | } |
| | 60 | |
|
| | 61 | | public void SetUserTalking(string payload) |
| | 62 | | { |
| 0 | 63 | | var model = JsonUtility.FromJson<UserTalkingModel>(payload); |
| 0 | 64 | | HUDController.i.voiceChatHud?.SetUserRecording(model.userId, model.talking); |
| 0 | 65 | | } |
| | 66 | |
|
| | 67 | | public void SetUsersMuted(string payload) |
| | 68 | | { |
| 0 | 69 | | var model = JsonUtility.FromJson<UserMutedModel>(payload); |
| 0 | 70 | | HUDController.i.voiceChatHud?.SetUsersMuted(model.usersId, model.muted); |
| 0 | 71 | | } |
| | 72 | |
|
| 0 | 73 | | public void RequestTeleport(string teleportDataJson) { DataStore.i.world.requestTeleportData.Set(teleportDataJson, t |
| | 74 | |
|
| | 75 | | public void UpdateBalanceOfMANA(string balance) |
| | 76 | | { |
| 0 | 77 | | HUDController.i.profileHud?.SetManaBalance(balance); |
| 0 | 78 | | DataStore.i.wallet.currentEthereumManaBalance.Set(Convert.ToDouble(balance)); |
| 0 | 79 | | } |
| | 80 | |
|
| | 81 | | [Obsolete("Old kernel might be using this call")] |
| | 82 | | public void ShowAvatarEditorInSignUp() |
| | 83 | | { |
| 0 | 84 | | SetSignupFlow(); |
| 0 | 85 | | } |
| | 86 | |
|
| | 87 | | public void SetSignupFlow() |
| | 88 | | { |
| 0 | 89 | | if (DataStore.i.featureFlags.flags.Get().IsFeatureEnabled("seamless_login_variant:enabled")) |
| 0 | 90 | | DataStore.i.HUDs.tosPopupVisible.Set(true, true); |
| | 91 | | else |
| | 92 | | { |
| 0 | 93 | | DataStore.i.common.isSignUpFlow.Set(true); |
| 0 | 94 | | DataStore.i.HUDs.avatarEditorVisible.Set(true, true); |
| | 95 | | } |
| 0 | 96 | | } |
| | 97 | |
|
| | 98 | | #endregion |
| | 99 | | } |