protected override void OnThreadUnSafeEventFired(object source, GenericSocialEventArgs <GuildMemberInviteEventModel> args) { UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() => { //TODO: We need a better way to handle guild query. //We need to translate the names first. var nameQueryResponse = await NameQueryService.RetrieveGuildNameAsync(args.Data.GuildId) .ConfigureAwait(true); string inviterName = await EntityNameQueryable.RetrieveAsync(args.Data.InviterGuid) .ConfigureAwait(true); TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"{inviterName} invited you to join the guild <{nameQueryResponse.Result.EntityName}>.", ChatChannelType.System)); }); }
protected override void OnEventFired(object source, CharacterJoinedGuildEventArgs args) { //If it's a hidden join then the client shouldn't write it to the chat box. if (args.isHiddenJoin) { return; } UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() => { string inviterName = await EntityNameQueryable.RetrieveAsync(args.JoineeGuid) .ConfigureAwait(true); TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"[{inviterName}] has joined the guild.", ChatChannelType.System)); }); }
/// <inheritdoc /> public async Task OnGameInitialized() { try { CharacterListResponse listResponse = await CharacterServiceQueryable.GetCharacters() .ConfigureAwaitFalse(); //TODO: Handle errors foreach (var character in listResponse.CharacterIds) { var entityGuid = new NetworkEntityGuidBuilder() .WithId(character) .WithType(EntityType.Player) .Build(); //TODO: Optimize below awaits. //Do a namequery so it's in the cache for when anything tries to get entities name. await EntityNameQueryable.RetrieveAsync(entityGuid) .ConfigureAwaitFalse(); var appearanceResponse = await CharacterServiceQueryable.GetCharacterAppearance(entityGuid.EntityId) .ConfigureAwaitFalse(); var characterData = await CharacterServiceQueryable.GetCharacterData(entityGuid.EntityId) .ConfigureAwaitFalse(); //Don't throw, because we actually don't want to stop the //character screen from working just because we can't visually display some stuff. if (!appearanceResponse.isSuccessful) { Logger.Error($"Failed to query for Character: {entityGuid.EntityId} appearance. Reason: {appearanceResponse.ResultCode}"); } //TODO: Handle errors. CharacterAppearanceMappable.AddObject(entityGuid, appearanceResponse.Result); InitialCharacterDataInstance.AddObject(entityGuid, characterData.Result); OnCharacterSelectionEntryChanged?.Invoke(this, new CharacterSelectionEntryDataChangeEventArgs(entityGuid)); } } catch (Exception e) { Logger.Error($"Encountered Error: {e.Message}"); throw; } }
protected override void OnThreadUnSafeEventFired(object source, GenericSocialEventArgs <GuildMemberInviteEventModel> args) { UnityAsyncHelper.UnityMainThreadContext.PostAsync(async() => { //We need to translate the names first. var nameQueryResponse = await NameQueryService.RetrieveGuildNameAsync(args.Data.GuildId) .ConfigureAwait(true); string inviterName = await EntityNameQueryable.RetrieveAsync(args.Data.InviterGuid) .ConfigureAwait(true); if (nameQueryResponse.isSuccessful) { GuildInviteWindow.GuildNameText.Text = $"<{nameQueryResponse.Result.EntityName}>"; GuildInviteWindow.InvitationText.Text = $"<color=green><b>{inviterName}</b></color> invites you to join the guild:"; //Now it can popup. GuildInviteWindow.SetElementActive(true); } }); }
protected override void OnEventFired(object source, GenericSocialEventArgs<GuildMemberInviteResponseModel> args) { UnityAsyncHelper.UnityMainThreadContext.PostAsync(async () => { string inviterName = args.Data.InvitedEntityGuid == NetworkEntityGuid.Empty ? "" : await EntityNameQueryable.RetrieveAsync(args.Data.InvitedEntityGuid) .ConfigureAwait(true); //Only certain response codes actually need to be logged. switch (args.Data.ResultCode) { case GuildMemberInviteResponseCode.GeneralServerError: TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"Failed to invite to guild due to server error.", ChatChannelType.System)); break; case GuildMemberInviteResponseCode.PlayerAlreadyInGuild: TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"{inviterName} is already in a guild.", ChatChannelType.System)); break; case GuildMemberInviteResponseCode.PlayerDeclinedGuildInvite: TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"{inviterName} declined your invite to join the guild.", ChatChannelType.System)); break; case GuildMemberInviteResponseCode.PlayerAlreadyHasPendingInvite: TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"{inviterName} already has a pending invite to join a guild.", ChatChannelType.System)); break; case GuildMemberInviteResponseCode.PlayerNotFound: TextChatPublisher.PublishEvent(this, new TextChatEventArgs($"Unable to invite player to guild; they either don't exist or are not online.", ChatChannelType.System)); break; } }); }