IBankController - jimdroberts/FishMMO GitHub Wiki
Interface for bank controllers, managing currency and item slots for a character's bank. Extends character behaviour and item container functionality.
-
long LastInteractableID { get; set; }
The ID of the last interactable bank object used by the player.
-
long Currency { get; set; }
The amount of currency stored in the bank.
-
bool CanSwapItemSlots(int from, int to, InventoryType fromInventory)
Determines if two item slots can be swapped, preventing invalid swaps (e.g., same slot). from (int): The source slot index. to (int): The destination slot index. fromInventory (InventoryType): The inventory type of the source slot. Returns: True if the slots can be swapped, false otherwise.
- Implement IBankController on your character or bank controller class.
- Provide logic for managing currency, item slots, and swap validation.
- Use the interface to allow characters to interact with and manage their bank inventory.
// Example 1: Implementing IBankController
public class MyBankController : IBankController {
public long LastInteractableID { get; set; }
public long Currency { get; set; }
public bool CanSwapItemSlots(int from, int to, InventoryType fromInventory) {
return from != to;
}
// Implement other ICharacterBehaviour and IItemContainer members...
}
// Example 2: Checking if slots can be swapped
bool canSwap = bankController.CanSwapItemSlots(0, 1, InventoryType.Bank);
- Always validate slot swaps to prevent invalid or redundant operations.
- Use the LastInteractableID to track which bank was accessed for context-sensitive logic.
- Implement all required members from ICharacterBehaviour and IItemContainer for full functionality.