FriendshipManager
A class in Root.Township, the global namespace.
Each Player has one. Holds that player's friend list, and on the client, whether that player is a friend of the local player. Data comes from the Alta social API.
- Listed in Global namespace: E to H
Constructors
| Member | What it is |
|---|---|
FriendshipManager() | Creates a FriendshipManager with default values. |
Fields
2 private and internal fields
Properties
| Member | What it is |
|---|---|
List<UserInfo> Friends { get; } | The friends' user info. Entries added by LocalStatusUpdate have the placeholder name [temp]. |
bool IsFriend { get; private set; } | Whether this player is friends with the local player. Used for name boards. |
bool IsUpdating { get; private set; } | True while GetFriends is waiting on the API. |
3 private and internal properties
Events
Methods
| Member | What it is |
|---|---|
void AddFriend(FriendshipInfo newFriendShip) | Adds a friend to the list. On the client also raises the update events. |
bool FriendRequestReceived(int player) | Whether this player has an incoming friend request from the given user. Only filled in for the local player. |
bool FriendRequestSent(int player) | Whether this player has sent a friend request to the given user. Only filled in for the local player. |
async Task GetFriends(bool isLocalPlayer) | Reloads the friend list from the API. For the local player it also loads sent and received requests. Skipped on clients for remote players. |
FriendshipType GetFriendshipType(int player) | Whether the given user is a friend, has a pending request either way, or neither. |
bool IsFriendsWith(int player) | Whether the given user ID is in this player's friend list. |
void LocalStatusUpdate(int playerId, FriendshipType newStatus) | Moves a user between friends, incoming and outgoing request lists without calling the API. |
void Setup(int player) | Sets which user ID this manager belongs to. |
async void UpdateFromNetwork(IPlayer player) | Asks the API whether this player and the given player are friends, then updates both managers. |
void UpdateStatus(bool isFriend) | Sets IsFriend and raises the events if it changed. |
void UpdateStatusWithPlayer(bool isFriend, int playerId) | Adds or removes a user ID from this player's friend list. |
Used in
Members of other types that take, return or hold a FriendshipManager: