/// <inheritdoc /> protected override void OnEventFired(object source, CharacterSelectionEntryDataChangeEventArgs args) { //At this point, we have a new character. BUT we don't know the name of it yet //We must query the name service for it. int slot = Interlocked.Increment(ref ButtonIndex); UnityExtended.UnityMainThreadContext.PostAsync(async() => { //TODO: Handle errors //TODO: We should expose NetworkEntityGuid endpoint string name = await NameQueryService.RetrieveAsync(args.CharacterEntityGuid.EntityId) .ConfigureAwait(true); //Once we have the result, we can assign the name. IUILabeledButton button = CharacterButtons.ElementAt(slot); button.Text = name; button.IsInteractable = true; //When clicked just broadcast a named event to everything that it has been clicked, and who it was. button.AddOnClickListener(() => OnCharacterButtonClicked?.Invoke(this, new CharacterButtonClickedEventArgs(args.CharacterEntityGuid, slot))); }); }
/// <inheritdoc /> protected override void OnEventFired(object source, TMenuChangeArgs args) { if (StaticButtons.Count <= MenuEntryRunningCount) { throw new InvalidOperationException($"Encountered Menu Entry Entry with MenuId: {args.Identifier} From: {typeof(TEventSubsribable).Name} With Args: {typeof(TMenuChangeArgs).Name} exceeding static menu size: {StaticButtons.Count}. CurrentCount: {MenuEntryRunningCount}"); } //Don't use menu identifier to get the index IUILabeledButton button = StaticButtons.ElementAt(MenuEntryRunningCount); Interlocked.Increment(ref MenuEntryRunningCount); button.IsInteractable = true; button.Text = args.MenuItemName; //TODO: Should we send networked menu click first before exposing click events to inheritor? button.AddOnClickListenerAsync(async() => await SendNetworkedMenuClick(args.Identifier)); if (isCustomEventsEnabled) { button.AddOnClickListenerAsync(async() => await OnButtonClickedAsync(MenuEntryRunningCount, args)); button.AddOnClickListener(() => OnButtonClicked(MenuEntryRunningCount, args)); } }