Skip to main content

RecentPlayerActionPage

A class in Root.Township, the global namespace.

Social tablet page for one recent player: friend, unfriend, mute, report, ban and unban buttons. Actions run on the client through the Alta API; reports and bans are also sent to the server, which raises console events.

Constructors​

MemberWhat it is
RecentPlayerActionPage()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

25 private and internal fields
MemberWhat it is
private IAnalyticsService analyticsServiceAnalytics service injected by VContainer.
private Button banButtonButton shown when you can ban and the player isn't banned.
private Panel banSentPageConfirmation page shown after a ban.
private List<RecentPlayerActionPage.FriendButtonMap> friendButtonsFriend buttons mapped to the friendship state each one is shown for.
private Panel friendRemovalSentPageConfirmation page shown after unfriending.
private Panel friendRequestAcceptSentPageConfirmation page shown after accepting a friend request.
private Panel friendRequestDenySentPageConfirmation page shown after denying a friend request.
private Panel friendRequestSentPageConfirmation page shown after sending a friend request.
private static readonly GroupPermissions[] groupBanPermissionFlagsThe permission checked by CanBanPlayersOnServer (only Ban).
private bool? hasBanPermissionResultCacheCached result of CanBanPlayersOnServer, null until asked.
private Button muteButtonButton shown while the player is not muted.
private const SocialAnalyticsEventOrigin OriginAnalytics origin for every event this page sends (the social tablet).
private RecentPlayerInteractionInfo recentPlayerThe recent player this page was set up for.
private RecentPlayerElement[] recentPlayerElementsElements (name, nameplate and so on) filled in with the recent player on Setup.
private ReportType reportReasonReason picked for the next report, set by SetReportReason.
private Panel reportSentPageConfirmation page shown after a report.
private JoinedGroupManager serverGroupManagerCacheCached result of GetServerGroupManager.
private GameServerInfo serverInfoCacheCached result of GetServerInfo.
private SocialTablet socialTabletThe tablet this page is on; its entity carries the sync messages.
private MethodSyncStruct<int> syncFriendshipStatusUpdateWithPlayerMessage (SyncC) for SyncFriendshipConfirmedWithPlayer, carrying the other player's user id.
private MethodSyncStruct<SocialTabletActionSyncStruct> syncSocialTabletActionMessage (SyncD) for SyncSocialTabletAction.
private TaskLock taskLockStops a second unfriend, deny, report, ban or unban from starting while one is running.
private Button unbanButtonButton shown when you can ban and the player is already banned.
private Panel unBanSentPageConfirmation page shown after an unban.
private Button unmuteButtonButton shown while the player is muted.

Properties​

4 private and internal properties
MemberWhat it is
private static bool IsServerIdValid { get; }False when there is no server id (-1), as on a local test.
private static int PlayerId { get; }User id of the local player.
private int RecentPlayerId { get; }User id of the recent player this page is showing.
private static int ServerId { get; }Current server id: from ServerHandler on the server, from JoinedServerInfo on a client.

Methods​

MemberWhat it is
async void BanPlayer()Bans the player from the current server through the API and tells the server, which raises SocialTabletPlayerBanned.
async void DenyFriendRequest()Declines the player's friend request by removing the friendship.
void InitSync()Creates the friendship and tablet action messages on the social tablet's entity.
void Inject(IAnalyticsService analyticsService)Receives the analytics service by dependency injection.
async void MakeFriendRequest()Sends a friend request (or accepts theirs) and shows the sent page.
async void ReportPlayer()Reports the player with the chosen reason and tells the server, which raises SocialTabletPlayerReported.
async void RespondFriendRequest()Accepts the player's friend request.
void SetReportReason(int reason)Sets the report reason from a ReportType number.
void Setup(RecentPlayerInteractionInfo recentPlayer)Shows a recent player: fills the elements and picks the right friend, mute and ban buttons. Ban buttons need the Ban group permission.
async void UnBanPlayer()Unbans the player from the current server and tells the server.
void Unfriend()Removes the friendship and tells the other player to refresh their friends list.
18 private and internal methods
MemberWhat it is
private async Task<bool> AddFriend()Sends a friend request through SocialService. If that makes you friends, refreshes the list and tells the other player via the server.
private void Awake()Hooks the mute and unmute buttons to ToggleMute.
private async Task BanPlayerTask()Bans the player from this server through SocialService, logs analytics and tells the server so it can raise a console event.
private async Task<bool> CanBanPlayersOnServer()Asks the API whether you have Ban permission in the server's group. False on local servers; the result is cached.
private async Task DenyFriendRequestTask()Removes the pending friendship and shows the deny confirmation page.
private async Task<JoinedGroupManager> GetServerGroupManager()Gets (and caches) the API group manager for the server's group, used for the ban list.
private async Task<GameServerInfo> GetServerInfo()Gets (and caches) this server's info from the API.
private async Task<bool> IsPlayerBanned(int playerId)Checks the server group's ban list through the API for the given user id.
private async Task<bool> RemoveFriend()Removes the friendship through SocialService and tells the other player via the server.
private async Task ReportPlayerTask()Reports the player with the chosen reason, logs analytics and tells the server so it can raise a console event.
private async void SetupBanButton()Shows the ban or unban button depending on permission and whether the player is already banned. Hides both without permission.
private void SetupFriendshipButton()Shows only the friend button that matches the current friendship state.
private void ShowCorrectMuteButton(bool isMuted)Shows mute or unmute to match whether the player is muted.
private void SyncFriendshipConfirmedWithPlayer(IPlayer player, Stream stream, int addedPlayerId)Server relays a friendship change to the named player; the client that gets it reloads its friend list.
private async void SyncSocialTabletAction(IPlayer player, Stream stream, SocialTabletActionSyncStruct actionData)Carries a report, ban or unban to the server, which looks the target up and fires the matching ConsoleEvents event.
private void ToggleMute(Button _)Flips voice chat mute for the player and swaps the buttons.
private async Task UnbanPlayerTask()Unbans the player through SocialService and tells the server. On a local test it only logs a warning.
private async Task UnfriendTask()Removes the friendship and shows the removal confirmation page.

Used in​

Members of other types that take, return or hold a RecentPlayerActionPage: