IBankController - jimdroberts/FishMMO GitHub Wiki

Description

Interface for bank controllers, managing currency and item slots for a character's bank. Extends character behaviour and item container functionality.


API Access

Properties

  • 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.

Methods

  • 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.


Basic Usage

Setup

  1. Implement IBankController on your character or bank controller class.
  2. Provide logic for managing currency, item slots, and swap validation.
  3. Use the interface to allow characters to interact with and manage their bank inventory.

Example

// 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);

Best Practices

  • 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.
⚠️ **GitHub.com Fallback** ⚠️