HotkeySystem - jimdroberts/FishMMO GitHub Wiki

Description

The HotkeySystem is a server-side system in FishMMO responsible for managing player hotkeys. It registers and handles network broadcasts for setting single or multiple hotkeys, validates hotkey data, and updates the player's hotkey list accordingly. The system ensures that all hotkey changes are validated and synchronized between the server and client.


API Access

Methods

  • public override void InitializeOnce()

    Initializes the hotkey system, registering broadcast handlers for hotkey set and hotkey set multiple requests.

  • public override void Destroying()

    Cleans up the hotkey system, unregistering broadcast handlers.

  • public void OnServerHotkeySetBroadcastReceived(NetworkConnection conn, HotkeySetBroadcast msg, Channel channel)

    Handles broadcast to set a single hotkey for a player character. Validates the hotkey list and slot, then updates the hotkey data for the specified slot. conn (NetworkConnection): Network connection of the requesting client. msg (HotkeySetBroadcast): Message containing hotkey data. channel (Channel): Network channel used for the broadcast.

  • public void OnServerHotkeySetMultipleBroadcastReceived(NetworkConnection conn, HotkeySetMultipleBroadcast msg, Channel channel)

    Handles broadcast to set multiple hotkeys for a player character. Iterates through each hotkey message, validates the hotkey list and slot, then updates the hotkey data for each slot. conn (NetworkConnection): Network connection of the requesting client. msg (HotkeySetMultipleBroadcast): Message containing multiple hotkey data entries. channel (Channel): Network channel used for the broadcast.


Basic Usage

Setup

  1. Requires the server to be running and the hotkey system to be initialized as part of the server startup.
  2. The system automatically registers broadcast handlers for hotkey set and hotkey set multiple requests.
  3. No manual registration is required unless extending or customizing hotkey logic.

Example

// Example 1: Setting a single hotkey (server-side)
// This is handled automatically by the system when a HotkeySetBroadcast is received from a client.
// No manual invocation is required unless extending or customizing the logic.

// Example 2: Setting multiple hotkeys (server-side)
// This is handled automatically by the system when a HotkeySetMultipleBroadcast is received from a client.
// No manual invocation is required unless extending or customizing the logic.

Best Practices

  • Always validate hotkey data and slot indices to prevent exploits or errors.
  • Use the provided broadcast handlers to extend or customize hotkey logic if needed.
  • Ensure all hotkey changes are properly synchronized between the server and client.
  • Avoid direct manipulation of hotkey lists outside of the provided interfaces and system methods.
⚠️ **GitHub.com Fallback** ⚠️