BankBroadcasts - jimdroberts/FishMMO GitHub Wiki
Defines broadcast structures for bank inventory actions, including setting, removing, and swapping items. Used for networked communication of bank inventory changes between client and server.
-
public struct BankSetItemBroadcast : IBroadcast
Broadcast for setting a single item in the bank inventory. Contains all data needed to place or update an item in a bank slot.
- long InstanceID: Unique instance ID of the item.
- int TemplateID: Template ID of the item type.
- int Slot: Slot index in the bank inventory.
- int Seed: Seed value for item randomization or uniqueness.
- uint StackSize: Stack size of the item.
-
public struct BankSetMultipleItemsBroadcast : IBroadcast
Broadcast for setting multiple items in the bank inventory at once. Used for bulk updates or synchronization.
- List Items: List of items to set in the bank.
-
public struct BankRemoveItemBroadcast : IBroadcast
Broadcast for removing an item from a specific bank slot.
- int Slot: Slot index to remove the item from.
-
public struct BankSwapItemSlotsBroadcast : IBroadcast
Broadcast for swapping two item slots in the bank or between inventories.
- int From: Source slot index.
- int To: Destination slot index.
- InventoryType FromInventory: Type of inventory the item is being moved from.
- Use these broadcast structs to send and receive bank inventory actions between client and server.
- Populate the fields as required for each bank operation (set, remove, swap, etc.).
// Example 1: Setting a single item in the bank
BankSetItemBroadcast setItem = new BankSetItemBroadcast {
InstanceID = 12345,
TemplateID = 1001,
Slot = 5,
Seed = 42,
StackSize = 10
};
networkManager.ClientManager.Broadcast(setItem);
// Example 2: Swapping two item slots
BankSwapItemSlotsBroadcast swap = new BankSwapItemSlotsBroadcast {
From = 2,
To = 7,
FromInventory = InventoryType.Bank
};
networkManager.ClientManager.Broadcast(swap);
- Always validate slot indices and item data before sending or processing broadcasts.
- Use bulk updates for efficient synchronization of large inventories.
- Keep inventory logic modular and well-documented for maintainability.
- Use the provided broadcast structs for clear, type-safe network communication.