Skip to main content

FriendSelector

A class in Root.Township, the global namespace.

Networked scroller for picking one of a player's friends. Syncs the list as user IDs, and each client keeps only the ones in its own friends list. SetPlayer is empty in this build, so nothing fills the list.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private IPlayer currentPlayerNot used in this build.
private Task filteringTaskNot used in this build.
private List<UserInfo> friendsThe friends shown, as user ID and username.
private bool isCancellingNot used in this build.
private static Logger loggerClass logger.
private ScrollerSelector scrollerThe scroller that shows the friend names.
private MethodSync syncFilterMethod sync for the friend list (SyncB).

Properties​

MemberWhat it is
int CurrentFriend { get; }User ID of the friend under the scroller, or -1 with no friends.

Events​

MemberWhat it is
event Action<int> UpdatedFriendSelectionRaised with the user ID of the newly selected friend.
event Action<IProvideEnumerable<string>> UpdatedValuesRaised when the friend list changes, with this as the source of names.

Methods​

MemberWhat it is
override void Initialize()Sets up the friend list sync and listens to the scroller.
async void SetPlayer(IPlayer player)Empty in this build.
2 private and internal methods
MemberWhat it is
private void SyncFilter(IPlayer player, Stream stream)Writes the friend IDs, or reads them and rebuilds the list from the local player's friends, then raises UpdatedValues.
private void UpdateFriend(int index)Scroller handler that raises UpdatedFriendSelection with the chosen friend's ID.

Used in​

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