CharacterAttributeBroadcasts - jimdroberts/FishMMO GitHub Wiki

Description

Defines broadcast structures for character attribute updates, including single and multiple updates for both standard and resource attributes. Used for networked communication of attribute changes between client and server.


API Access

Fields

  • public struct CharacterAttributeUpdateBroadcast : IBroadcast

    Broadcast for updating a single character attribute (e.g., strength, agility). Contains the template ID and the new value for the attribute.

    • int TemplateID: Template ID of the attribute to update.
    • int Value: New value for the attribute.
  • public struct CharacterResourceAttributeUpdateBroadcast : IBroadcast

    Broadcast for updating a character's resource attribute (e.g., health, mana). Contains the template ID, current value, and maximum value.

    • int TemplateID: Template ID of the resource attribute to update.
    • int CurrentValue: Current value of the resource (e.g., current health).
    • int Value: Maximum value of the resource (e.g., max health).
  • public struct CharacterAttributeUpdateMultipleBroadcast : IBroadcast

    Broadcast for updating multiple character attributes at once. Used for bulk attribute updates or synchronization.

    • List Attributes: List of attribute updates to apply.
  • public struct CharacterResourceAttributeUpdateMultipleBroadcast : IBroadcast

    Broadcast for updating multiple character resource attributes at once. Used for bulk resource attribute updates or synchronization.

    • List Attributes: List of resource attribute updates to apply.

Basic Usage

Setup

  1. Use these broadcast structs to send and receive attribute updates between client and server.
  2. Populate the fields as required for each attribute update operation (single, bulk, etc.).

Example

// Example 1: Updating a single attribute
CharacterAttributeUpdateBroadcast update = new CharacterAttributeUpdateBroadcast {
    TemplateID = 5001,
    Value = 15
};
networkManager.ClientManager.Broadcast(update);

// Example 2: Bulk updating resource attributes
CharacterResourceAttributeUpdateMultipleBroadcast bulkUpdate = new CharacterResourceAttributeUpdateMultipleBroadcast {
    Attributes = new List<CharacterResourceAttributeUpdateBroadcast> {
        new CharacterResourceAttributeUpdateBroadcast { TemplateID = 6001, CurrentValue = 80, Value = 100 },
        new CharacterResourceAttributeUpdateBroadcast { TemplateID = 6002, CurrentValue = 40, Value = 50 }
    }
};
networkManager.ClientManager.Broadcast(bulkUpdate);

Best Practices

  • Always validate attribute template IDs and values before sending or processing broadcasts.
  • Use bulk updates for efficient synchronization of multiple attributes.
  • Keep attribute logic modular and well-documented for maintainability.
  • Use the provided broadcast structs for clear, type-safe network communication.
⚠️ **GitHub.com Fallback** ⚠️