| | 1 | | using AvatarSystem; |
| | 2 | | using Cysharp.Threading.Tasks; |
| | 3 | | using System.Collections.Generic; |
| | 4 | | using DCL.Emotes; |
| | 5 | | using DCL.Helpers; |
| | 6 | | using DCLServices.WearablesCatalogService; |
| | 7 | | using System.Linq; |
| | 8 | | using System.Threading; |
| | 9 | | using UnityEngine; |
| | 10 | | using UnityEngine.Pool; |
| | 11 | |
|
| | 12 | | namespace DCL.EmotesWheel |
| | 13 | | { |
| | 14 | | public class EmotesWheelController : IHUD |
| | 15 | | { |
| | 16 | | internal EmotesWheelView view; |
| 13 | 17 | | private BaseVariable<bool> emotesVisible => DataStore.i.HUDs.emotesVisible; |
| 5 | 18 | | private BaseVariable<bool> emoteJustTriggeredFromShortcut => DataStore.i.HUDs.emoteJustTriggeredFromShortcut; |
| 0 | 19 | | private BaseVariable<bool> isAvatarEditorVisible => DataStore.i.HUDs.avatarEditorVisible; |
| 4 | 20 | | private BaseVariable<bool> isStartMenuOpen => DataStore.i.exploreV2.isOpen; |
| 5 | 21 | | private BaseVariable<bool> canStartMenuBeOpened => DataStore.i.exploreV2.isSomeModalOpen; |
| 0 | 22 | | private bool shortcutsCanBeUsed => !isStartMenuOpen.Get(); |
| 9 | 23 | | private DataStore_EmotesCustomization emotesCustomizationDataStore => DataStore.i.emotesCustomization; |
| | 24 | |
|
| 6 | 25 | | private UserProfile ownUserProfile => UserProfile.GetOwnUserProfile(); |
| | 26 | | private InputAction_Trigger closeWindow; |
| | 27 | | private InputAction_Hold openEmotesCustomizationInputAction; |
| | 28 | | private InputAction_Trigger shortcut0InputAction; |
| | 29 | | private InputAction_Trigger shortcut1InputAction; |
| | 30 | | private InputAction_Trigger shortcut2InputAction; |
| | 31 | | private InputAction_Trigger shortcut3InputAction; |
| | 32 | | private InputAction_Trigger shortcut4InputAction; |
| | 33 | | private InputAction_Trigger shortcut5InputAction; |
| | 34 | | private InputAction_Trigger shortcut6InputAction; |
| | 35 | | private InputAction_Trigger shortcut7InputAction; |
| | 36 | | private InputAction_Trigger shortcut8InputAction; |
| | 37 | | private InputAction_Trigger shortcut9InputAction; |
| | 38 | | private InputAction_Trigger auxShortcut0InputAction; |
| | 39 | | private InputAction_Trigger auxShortcut1InputAction; |
| | 40 | | private InputAction_Trigger auxShortcut2InputAction; |
| | 41 | | private InputAction_Trigger auxShortcut3InputAction; |
| | 42 | | private InputAction_Trigger auxShortcut4InputAction; |
| | 43 | | private InputAction_Trigger auxShortcut5InputAction; |
| | 44 | | private InputAction_Trigger auxShortcut6InputAction; |
| | 45 | | private InputAction_Trigger auxShortcut7InputAction; |
| | 46 | | private InputAction_Trigger auxShortcut8InputAction; |
| | 47 | | private InputAction_Trigger auxShortcut9InputAction; |
| | 48 | | private readonly UserProfile userProfile; |
| | 49 | | private readonly IWearablesCatalogService wearablesCatalogService; |
| | 50 | | private bool ownedWearablesAlreadyRequested; |
| 3 | 51 | | private readonly BaseDictionary<string, EmoteWheelSlot> slotsInLoadingState = new (); |
| 3 | 52 | | private CancellationTokenSource cts = new (); |
| | 53 | | private readonly IEmotesCatalogService emoteCatalog; |
| | 54 | | private readonly IEmotesService emotesService; |
| | 55 | | private IAvatar avatar; |
| | 56 | | private IAvatarEmotesController emotesController; |
| | 57 | |
|
| 3 | 58 | | public EmotesWheelController( |
| | 59 | | UserProfile userProfile, |
| | 60 | | IEmotesService emotesService, |
| | 61 | | IWearablesCatalogService wearablesCatalogService) |
| | 62 | | { |
| 3 | 63 | | this.emotesService = emotesService; |
| 3 | 64 | | closeWindow = Resources.Load<InputAction_Trigger>("CloseWindow"); |
| 3 | 65 | | closeWindow.OnTriggered += OnCloseWindowPressed; |
| | 66 | |
|
| 3 | 67 | | view = EmotesWheelView.Create(); |
| 3 | 68 | | view.OnClose += OnViewClosed; |
| 3 | 69 | | view.onEmoteClicked += OnEmoteClicked; |
| 3 | 70 | | view.OnCustomizeClicked += OpenEmotesCustomizationSection; |
| | 71 | |
|
| 3 | 72 | | ownUserProfile.OnAvatarEmoteSet += OnAvatarEmoteSet; |
| 3 | 73 | | emotesVisible.OnChange += OnEmoteVisibleChanged; |
| 3 | 74 | | OnEmoteVisibleChanged(emotesVisible.Get(), false); |
| | 75 | |
|
| 3 | 76 | | isStartMenuOpen.OnChange += IsStartMenuOpenChanged; |
| | 77 | |
|
| 3 | 78 | | this.userProfile = userProfile; |
| 3 | 79 | | this.wearablesCatalogService = wearablesCatalogService; |
| 3 | 80 | | emotesCustomizationDataStore.equippedEmotes.OnSet += OnEquippedEmotesSet; |
| | 81 | |
|
| 3 | 82 | | ConfigureShortcuts(); |
| | 83 | |
|
| 3 | 84 | | emotesCustomizationDataStore.isWheelInitialized.Set(true); |
| | 85 | |
|
| 3 | 86 | | DataStore.i.player.ownPlayer.OnChange += OnPlayerSet; |
| 3 | 87 | | OnPlayerSet(DataStore.i.player.ownPlayer.Get(), null); |
| 3 | 88 | | } |
| | 89 | |
|
| | 90 | | private void OnPlayerSet(Player current, Player previous) |
| | 91 | | { |
| 6 | 92 | | if (current == null) return; |
| 0 | 93 | | emotesController = current.avatar.GetEmotesController(); |
| 0 | 94 | | emotesController.OnEmoteEquipped += OnEmoteEquipped; |
| 0 | 95 | | UpdateEmoteSlots(); |
| 0 | 96 | | } |
| | 97 | |
|
| | 98 | | private void OnEmoteEquipped(string emoteId, IEmoteReference emoteReference) |
| | 99 | | { |
| 0 | 100 | | RefreshSlotLoadingState(emoteId); |
| 0 | 101 | | } |
| | 102 | |
|
| | 103 | | public void SetVisibility(bool visible) |
| | 104 | | { |
| | 105 | | //TODO once kernel sends visible properly |
| | 106 | | //expressionsVisible.Set(visible); |
| 0 | 107 | | } |
| | 108 | |
|
| 10 | 109 | | private void OnEmoteVisibleChanged(bool current, bool previous) { SetVisibility_Internal(current); } |
| | 110 | |
|
| | 111 | | private void IsStartMenuOpenChanged(bool current, bool previous) |
| | 112 | | { |
| 0 | 113 | | if (!current) |
| 0 | 114 | | return; |
| | 115 | |
|
| 0 | 116 | | emotesVisible.Set(false); |
| 0 | 117 | | } |
| | 118 | |
|
| 0 | 119 | | private void OnEquippedEmotesSet(IEnumerable<EquippedEmoteData> equippedEmotes) { UpdateEmoteSlots(); } |
| | 120 | |
|
| | 121 | | private void UpdateEmoteSlots() |
| | 122 | | { |
| 0 | 123 | | if (emotesController == null) return; |
| 0 | 124 | | List<EmotesWheelView.EmoteSlotData> emotesToSet = new List<EmotesWheelView.EmoteSlotData>(); |
| | 125 | |
|
| 0 | 126 | | var equippedEmotes = ListPool<EquippedEmoteData>.Get(); |
| 0 | 127 | | equippedEmotes.AddRange(emotesCustomizationDataStore.equippedEmotes.Get()); |
| | 128 | |
|
| 0 | 129 | | foreach (EquippedEmoteData equippedEmoteData in equippedEmotes) |
| | 130 | | { |
| 0 | 131 | | if (equippedEmoteData != null) |
| | 132 | | { |
| 0 | 133 | | if (emotesController.TryGetEquippedEmote(userProfile.avatar.bodyShape, equippedEmoteData.id, out var |
| | 134 | | { |
| 0 | 135 | | var entity = emote?.GetEntity(); |
| | 136 | |
|
| 0 | 137 | | if (entity == null) // emote exists but its not loaded yet |
| | 138 | | { |
| 0 | 139 | | emotesToSet.Add(new EmotesWheelView.EmoteSlotData |
| | 140 | | { |
| | 141 | | emoteId = equippedEmoteData.id, |
| | 142 | | emoteItem = null, |
| | 143 | | thumbnailSprite = equippedEmoteData.cachedThumbnail, |
| | 144 | | }); |
| | 145 | | } |
| | 146 | | else |
| | 147 | | { |
| 0 | 148 | | emotesToSet.Add(new EmotesWheelView.EmoteSlotData |
| | 149 | | { |
| | 150 | | emoteId = equippedEmoteData.id, |
| | 151 | | emoteItem = entity, |
| | 152 | | thumbnailSprite = entity.thumbnailSprite != null ? entity.thumbnailSprite : equippedEmot |
| | 153 | | }); |
| | 154 | | } |
| | 155 | | } |
| | 156 | | else |
| 0 | 157 | | emotesToSet.Add(new EmotesWheelView.EmoteSlotData |
| | 158 | | { |
| | 159 | | emoteId = equippedEmoteData.id, |
| | 160 | | emoteItem = null, |
| | 161 | | thumbnailSprite = equippedEmoteData.cachedThumbnail, |
| | 162 | | }); |
| | 163 | | } else |
| 0 | 164 | | emotesToSet.Add(null); |
| | 165 | | } |
| | 166 | |
|
| 0 | 167 | | ListPool<EquippedEmoteData>.Release(equippedEmotes); |
| | 168 | |
|
| 0 | 169 | | List<EmoteWheelSlot> updatedWheelSlots = view.SetEmotes(emotesToSet); |
| 0 | 170 | | foreach (EmoteWheelSlot slot in updatedWheelSlots) |
| | 171 | | { |
| 0 | 172 | | slot.SetAsLoading(false); |
| 0 | 173 | | if (string.IsNullOrEmpty(slot.emoteId)) |
| | 174 | | continue; |
| | 175 | |
|
| 0 | 176 | | slotsInLoadingState.Remove(slot.emoteId); |
| | 177 | |
|
| | 178 | |
|
| 0 | 179 | | slot.SetAsLoading(true); |
| 0 | 180 | | slotsInLoadingState.Add(slot.emoteId, slot); |
| | 181 | |
|
| 0 | 182 | | RefreshSlotLoadingState(slot.emoteId); |
| | 183 | | } |
| 0 | 184 | | } |
| | 185 | |
|
| | 186 | | private void RefreshSlotLoadingState(string emoteId) |
| | 187 | | { |
| 0 | 188 | | if (emotesController.TryGetEquippedEmote(userProfile.avatar.bodyShape, emoteId, out var emote)) |
| | 189 | | { |
| 0 | 190 | | slotsInLoadingState.TryGetValue(emoteId, out EmoteWheelSlot slot); |
| 0 | 191 | | if (slot == null) return; |
| 0 | 192 | | var entity = emote.GetEntity(); |
| 0 | 193 | | view.SetupEmoteWheelSlot(slot, new EmotesWheelView.EmoteSlotData |
| | 194 | | { |
| | 195 | | emoteId = emoteId, |
| | 196 | | emoteItem = entity, |
| | 197 | | thumbnailSprite = entity.thumbnailSprite, |
| | 198 | | }); |
| 0 | 199 | | slot.SetAsLoading(false); |
| 0 | 200 | | slotsInLoadingState.Remove(emoteId); |
| | 201 | | } |
| 0 | 202 | | } |
| | 203 | |
|
| | 204 | | public void SetVisibility_Internal(bool visible) |
| | 205 | | { |
| | 206 | | async UniTaskVoid RequestOwnedWearablesAsync(CancellationToken ct) |
| | 207 | | { |
| 0 | 208 | | var ownedWearables = await wearablesCatalogService.RequestOwnedWearablesAsync( |
| | 209 | | userProfile.userId, |
| | 210 | | 1, |
| | 211 | | int.MaxValue, |
| | 212 | | true, |
| | 213 | | ct); |
| | 214 | |
|
| 0 | 215 | | ownedWearablesAlreadyRequested = true; |
| 0 | 216 | | userProfile.SetInventory(ownedWearables.wearables.Select(x => x.id)); |
| 0 | 217 | | UpdateEmoteSlots(); |
| 0 | 218 | | } |
| | 219 | |
|
| 5 | 220 | | if (visible && isStartMenuOpen.Get()) |
| 0 | 221 | | return; |
| | 222 | |
|
| 5 | 223 | | if (emoteJustTriggeredFromShortcut.Get()) |
| | 224 | | { |
| 0 | 225 | | emotesVisible.Set(false); |
| 0 | 226 | | return; |
| | 227 | | } |
| | 228 | |
|
| 5 | 229 | | view.SetVisiblity(visible); |
| | 230 | |
|
| 5 | 231 | | if (visible) |
| | 232 | | { |
| 1 | 233 | | Helpers.Utils.UnlockCursor(); |
| | 234 | |
|
| 1 | 235 | | if (userProfile != null && |
| | 236 | | !string.IsNullOrEmpty(userProfile.userId) && |
| | 237 | | !ownedWearablesAlreadyRequested) |
| | 238 | | { |
| 0 | 239 | | cts?.Cancel(); |
| 0 | 240 | | cts?.Dispose(); |
| 0 | 241 | | cts = new CancellationTokenSource(); |
| 0 | 242 | | RequestOwnedWearablesAsync(cts.Token).Forget(); |
| | 243 | | } |
| | 244 | | } |
| | 245 | |
|
| 5 | 246 | | canStartMenuBeOpened.Set(visible); |
| 5 | 247 | | } |
| | 248 | |
|
| | 249 | | public void Dispose() |
| | 250 | | { |
| 3 | 251 | | view.OnClose -= OnViewClosed; |
| 3 | 252 | | view.onEmoteClicked -= OnEmoteClicked; |
| 3 | 253 | | view.OnCustomizeClicked -= OpenEmotesCustomizationSection; |
| 3 | 254 | | closeWindow.OnTriggered -= OnCloseWindowPressed; |
| 3 | 255 | | ownUserProfile.OnAvatarEmoteSet -= OnAvatarEmoteSet; |
| 3 | 256 | | emotesVisible.OnChange -= OnEmoteVisibleChanged; |
| 3 | 257 | | emotesCustomizationDataStore.equippedEmotes.OnSet -= OnEquippedEmotesSet; |
| 3 | 258 | | shortcut0InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 259 | | shortcut1InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 260 | | shortcut2InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 261 | | shortcut3InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 262 | | shortcut4InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 263 | | shortcut5InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 264 | | shortcut6InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 265 | | shortcut7InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 266 | | shortcut8InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 267 | | shortcut9InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 268 | | auxShortcut0InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 269 | | auxShortcut1InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 270 | | auxShortcut2InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 271 | | auxShortcut3InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 272 | | auxShortcut4InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 273 | | auxShortcut5InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 274 | | auxShortcut6InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 275 | | auxShortcut7InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 276 | | auxShortcut8InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| 3 | 277 | | auxShortcut9InputAction.OnTriggered -= OnNumericShortcutInputActionTriggered; |
| | 278 | |
|
| 3 | 279 | | if (emotesController != null) |
| 0 | 280 | | emotesController.OnEmoteEquipped -= OnEmoteEquipped; |
| | 281 | |
|
| 3 | 282 | | cts?.Cancel(); |
| 3 | 283 | | cts?.Dispose(); |
| 3 | 284 | | cts = null; |
| | 285 | |
|
| 3 | 286 | | if (view != null) |
| | 287 | | { |
| 3 | 288 | | view.CleanUp(); |
| 3 | 289 | | Utils.SafeDestroy(view.gameObject); |
| | 290 | | } |
| 3 | 291 | | } |
| | 292 | |
|
| 0 | 293 | | public void OnEmoteClicked(string id) { PlayEmote(id, UserProfile.EmoteSource.EmotesWheel); } |
| | 294 | |
|
| | 295 | | public void PlayEmote(string id, UserProfile.EmoteSource source) |
| | 296 | | { |
| 1 | 297 | | if (string.IsNullOrEmpty(id)) |
| 0 | 298 | | return; |
| | 299 | |
|
| 1 | 300 | | UserProfile.GetOwnUserProfile().SetAvatarExpression(id, source); |
| 1 | 301 | | } |
| | 302 | |
|
| | 303 | | private void ConfigureShortcuts() |
| | 304 | | { |
| 3 | 305 | | closeWindow = Resources.Load<InputAction_Trigger>("CloseWindow"); |
| 3 | 306 | | closeWindow.OnTriggered += OnCloseWindowPressed; |
| | 307 | |
|
| 3 | 308 | | openEmotesCustomizationInputAction = Resources.Load<InputAction_Hold>("DefaultConfirmAction"); |
| 3 | 309 | | openEmotesCustomizationInputAction.OnFinished += OnOpenEmotesCustomizationInputActionTriggered; |
| | 310 | |
|
| 3 | 311 | | shortcut0InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut0"); |
| 3 | 312 | | shortcut0InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 313 | |
|
| 3 | 314 | | shortcut1InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut1"); |
| 3 | 315 | | shortcut1InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 316 | |
|
| 3 | 317 | | shortcut2InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut2"); |
| 3 | 318 | | shortcut2InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 319 | |
|
| 3 | 320 | | shortcut3InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut3"); |
| 3 | 321 | | shortcut3InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 322 | |
|
| 3 | 323 | | shortcut4InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut4"); |
| 3 | 324 | | shortcut4InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 325 | |
|
| 3 | 326 | | shortcut5InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut5"); |
| 3 | 327 | | shortcut5InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 328 | |
|
| 3 | 329 | | shortcut6InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut6"); |
| 3 | 330 | | shortcut6InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 331 | |
|
| 3 | 332 | | shortcut7InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut7"); |
| 3 | 333 | | shortcut7InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 334 | |
|
| 3 | 335 | | shortcut8InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut8"); |
| 3 | 336 | | shortcut8InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 337 | |
|
| 3 | 338 | | shortcut9InputAction = Resources.Load<InputAction_Trigger>("ToggleEmoteShortcut9"); |
| 3 | 339 | | shortcut9InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 340 | |
|
| 3 | 341 | | auxShortcut0InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut0"); |
| 3 | 342 | | auxShortcut0InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 343 | |
|
| 3 | 344 | | auxShortcut1InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut1"); |
| 3 | 345 | | auxShortcut1InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 346 | |
|
| 3 | 347 | | auxShortcut2InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut2"); |
| 3 | 348 | | auxShortcut2InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 349 | |
|
| 3 | 350 | | auxShortcut3InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut3"); |
| 3 | 351 | | auxShortcut3InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 352 | |
|
| 3 | 353 | | auxShortcut4InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut4"); |
| 3 | 354 | | auxShortcut4InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 355 | |
|
| 3 | 356 | | auxShortcut5InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut5"); |
| 3 | 357 | | auxShortcut5InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 358 | |
|
| 3 | 359 | | auxShortcut6InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut6"); |
| 3 | 360 | | auxShortcut6InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 361 | |
|
| 3 | 362 | | auxShortcut7InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut7"); |
| 3 | 363 | | auxShortcut7InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 364 | |
|
| 3 | 365 | | auxShortcut8InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut8"); |
| 3 | 366 | | auxShortcut8InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| | 367 | |
|
| 3 | 368 | | auxShortcut9InputAction = Resources.Load<InputAction_Trigger>("ToggleShortcut9"); |
| 3 | 369 | | auxShortcut9InputAction.OnTriggered += OnNumericShortcutInputActionTriggered; |
| 3 | 370 | | } |
| | 371 | |
|
| | 372 | | private void OnNumericShortcutInputActionTriggered(DCLAction_Trigger action) |
| | 373 | | { |
| 0 | 374 | | if (!shortcutsCanBeUsed) |
| 0 | 375 | | return; |
| | 376 | |
|
| | 377 | | switch (action) |
| | 378 | | { |
| | 379 | | case DCLAction_Trigger.ToggleEmoteShortcut0: |
| 0 | 380 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[0]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 381 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 382 | | break; |
| | 383 | | case DCLAction_Trigger.ToggleEmoteShortcut1: |
| 0 | 384 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[1]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 385 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 386 | | break; |
| | 387 | | case DCLAction_Trigger.ToggleEmoteShortcut2: |
| 0 | 388 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[2]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 389 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 390 | | break; |
| | 391 | | case DCLAction_Trigger.ToggleEmoteShortcut3: |
| 0 | 392 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[3]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 393 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 394 | | break; |
| | 395 | | case DCLAction_Trigger.ToggleEmoteShortcut4: |
| 0 | 396 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[4]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 397 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 398 | | break; |
| | 399 | | case DCLAction_Trigger.ToggleEmoteShortcut5: |
| 0 | 400 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[5]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 401 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 402 | | break; |
| | 403 | | case DCLAction_Trigger.ToggleEmoteShortcut6: |
| 0 | 404 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[6]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 405 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 406 | | break; |
| | 407 | | case DCLAction_Trigger.ToggleEmoteShortcut7: |
| 0 | 408 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[7]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 409 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 410 | | break; |
| | 411 | | case DCLAction_Trigger.ToggleEmoteShortcut8: |
| 0 | 412 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[8]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 413 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 414 | | break; |
| | 415 | | case DCLAction_Trigger.ToggleEmoteShortcut9: |
| 0 | 416 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[9]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 417 | | emoteJustTriggeredFromShortcut.Set(true); |
| 0 | 418 | | break; |
| | 419 | | case DCLAction_Trigger.ToggleShortcut0: |
| 0 | 420 | | if (emotesVisible.Get()) |
| 0 | 421 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[0]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 422 | | break; |
| | 423 | | case DCLAction_Trigger.ToggleShortcut1: |
| 0 | 424 | | if (emotesVisible.Get()) |
| 0 | 425 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[1]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 426 | | break; |
| | 427 | | case DCLAction_Trigger.ToggleShortcut2: |
| 0 | 428 | | if (emotesVisible.Get()) |
| 0 | 429 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[2]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 430 | | break; |
| | 431 | | case DCLAction_Trigger.ToggleShortcut3: |
| 0 | 432 | | if (emotesVisible.Get()) |
| 0 | 433 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[3]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 434 | | break; |
| | 435 | | case DCLAction_Trigger.ToggleShortcut4: |
| 0 | 436 | | if (emotesVisible.Get()) |
| 0 | 437 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[4]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 438 | | break; |
| | 439 | | case DCLAction_Trigger.ToggleShortcut5: |
| 0 | 440 | | if (emotesVisible.Get()) |
| 0 | 441 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[5]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 442 | | break; |
| | 443 | | case DCLAction_Trigger.ToggleShortcut6: |
| 0 | 444 | | if (emotesVisible.Get()) |
| 0 | 445 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[6]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 446 | | break; |
| | 447 | | case DCLAction_Trigger.ToggleShortcut7: |
| 0 | 448 | | if (emotesVisible.Get()) |
| 0 | 449 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[7]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 450 | | break; |
| | 451 | | case DCLAction_Trigger.ToggleShortcut8: |
| 0 | 452 | | if (emotesVisible.Get()) |
| 0 | 453 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[8]?.id, UserProfile.EmoteSource.Shortcut); |
| 0 | 454 | | break; |
| | 455 | | case DCLAction_Trigger.ToggleShortcut9: |
| 0 | 456 | | if (emotesVisible.Get()) |
| 0 | 457 | | PlayEmote(emotesCustomizationDataStore.equippedEmotes[9]?.id, UserProfile.EmoteSource.Shortcut); |
| | 458 | | break; |
| | 459 | | } |
| 0 | 460 | | } |
| | 461 | |
|
| 0 | 462 | | private void OnViewClosed() { emotesVisible.Set(false); } |
| 2 | 463 | | private void OnAvatarEmoteSet(string id, long timestamp, UserProfile.EmoteSource source) { emotesVisible.Set(fal |
| 6 | 464 | | private void OnCloseWindowPressed(DCLAction_Trigger action) { emotesVisible.Set(false); } |
| | 465 | |
|
| | 466 | | private void OnOpenEmotesCustomizationInputActionTriggered(DCLAction_Hold action) |
| | 467 | | { |
| 0 | 468 | | if (!emotesVisible.Get()) |
| 0 | 469 | | return; |
| | 470 | |
|
| 0 | 471 | | OpenEmotesCustomizationSection(); |
| 0 | 472 | | } |
| | 473 | |
|
| | 474 | | private void OpenEmotesCustomizationSection() |
| | 475 | | { |
| 0 | 476 | | emotesVisible.Set(false); |
| 0 | 477 | | isAvatarEditorVisible.Set(true); |
| 0 | 478 | | emotesCustomizationDataStore.isEmotesCustomizationSelected.Set(true); |
| 0 | 479 | | } |
| | 480 | | } |
| | 481 | | } |