PostBoxSenderManager
A class in Root.Township, the global namespace.
Tracks how many gifts each player may still send to each other player through post boxes, with a cap of GiftsPerPlayer. The server keeps the counts and syncs each player their own; use the static instance.
- Listed in Global namespace: P
- Inherits or implements
NetworkEntityBehaviour - Nested types
PerPlayerSendingCount - Documented in Trading
Constructors
| Member | What it is |
|---|---|
PostBoxSenderManager() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
| Member | What it is |
|---|---|
static PostBoxSenderManager instance | The scene's instance, set in Awake. |
4 private and internal fields
| Member | What it is |
|---|---|
private int giftsPerPlayer | Backing field for GiftsPerPlayer. |
private Dictionary<int, PostBoxSenderManager.PerPlayerSendingCount> perPlayerCounter | Remaining allowance by sender user id, then by receiver user id. Not saved in this file. |
private MethodSync syncAll | Method sync for all counts. |
private MethodSyncStruct<int> syncSingle | Method sync for one count. |
Properties
| Member | What it is |
|---|---|
int GiftsPerPlayer { get; } | Gift allowance per sender and receiver pair (3 by default). |
Methods
| Member | What it is |
|---|---|
int GetAvailableQuantity(int fromIdentifier, int toIdentifier) | How many gifts one player can still send another. Full allowance if none have been sent. |
override void Initialize() | Creates the full and single count syncs. |
override void OnConnected(Player player) | Sends a joining remote player all their counts. |
void Retrieve(int fromIdentifier, int toIdentifier, int quantity) | Gives back allowance when a sent gift is taken back, up to the cap, and syncs the sender. |
void Send(int fromIdentifier, int toIdentifier, int quantity) | Uses up allowance for a gift from one player to another and syncs the sender. |
4 private and internal methods
| Member | What it is |
|---|---|
private void Awake() | Sets the static instance. |
private void SendToRemoteFromPlayer(int fromIdentifier, int toIdentifier) | Sends the sender their updated count for one receiver, unless the sender is the local player. |
private void SyncAll(IPlayer player, Stream stream) | Sends a player all their counts. Client: stores them under the logged-in user. |
private void SyncSingle(IPlayer player, Stream stream, int toIdentifier) | Sends a player their count for one receiver. Client: stores it. |