SentGift
A class in Root.Township, the global namespace.
A gift package from a postbox. PostboxSender spawns it on the server, fills it with the sent items and stores it in the receiver's postbox; spawning it out gives the receiver the items.
- Listed in Global namespace: S
- Inherits or implements
NetworkEntityBehaviour,ISavable<SentGiftData>,ISavableSave<SentGiftData>,ISavableSaveBase - Derived types
SentGiftData
Constructors
| Member | What it is |
|---|---|
SentGift() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
9 private and internal fields
| Member | What it is |
|---|---|
private string receiversName | Receiver's username. |
private TextRenderer receiversNameText | Text showing the receiver's name. |
private string sendersName | Sender's username. |
private TextRenderer sendersNameText | Text showing the sender's name. |
private SentGiftTag senderTag | Sender and receiver user IDs, used to track sent and retrieved gifts. |
private Transform spawnPosition | Centre point the items spawn around. |
private float spawnRadius | Radius of the random spread for spawned items. |
private MethodSync syncSetup | Method sync for the names. |
private SavableSavedDynamicObject[] toSpawn | The saved items inside the gift. |
Methods
| Member | What it is |
|---|---|
override void Initialize() | Creates the setup sync. |
override void InitializeAsServer(SpawnData spawnData) | Server: shows the names on the tag. |
override void OnConnected(Player player) | Server: sends the sender and receiver names to a joining player. |
void Setup(string sendersName, string receiversName, SentGiftTag senderTag, SavedDynamicObject[] toSpawn) | Server: sets the names, sender tag and the saved items to spawn. Called by PostboxSender. |
void Spawn() | Server: marks the gift as retrieved with PostBoxSenderManager, then spawns each item owned near spawnPosition in this chunk. |
3 private and internal methods
| Member | What it is |
|---|---|
private void OnDrawGizmosSelected() | Editor: draws the spawn radius. |
private void SyncSetup(IPlayer player, Stream stream) | Syncs the sender and receiver names and updates the tag on clients. |
private void UpdateNameTag() | Shows the sender and receiver names on the text renderers, except on headless. |