RegionApplyCharacterAttributeAction - jimdroberts/FishMMO GitHub Wiki

Description

RegionApplyCharacterAttributeAction is a region action ScriptableObject that applies a value to a character attribute or resource attribute on a player character when triggered within a region. It is used to modify attributes such as health, mana, or custom stats as part of region-based gameplay mechanics.


API Access

Fields

  • public CharacterAttributeTemplate attribute

    The attribute template to modify on the player character.

  • public int value

    The value to add to the attribute or resource attribute.

Methods

  • public override void Invoke(IPlayerCharacter character, Region region, bool isReconciling)

    Invokes the region action, modifying the specified attribute or resource attribute on the player character. Parameters: - IPlayerCharacter character: The player character whose attribute will be modified. - Region region: The region in which the action is triggered. - bool isReconciling: Indicates if the action is part of a reconciliation process.


Basic Usage

Setup

  1. Ensure a valid CharacterAttributeTemplate asset exists in your project.
  2. Create a new RegionApplyCharacterAttributeAction ScriptableObject via the Unity Editor (Assets > Create > FishMMO > Region > Region Apply Character Attribute).
  3. Assign the desired CharacterAttributeTemplate to the attribute field in the inspector.
  4. Set the value field to the amount you wish to add to the attribute.
  5. Attach the RegionApplyCharacterAttributeAction to a region's action list or trigger logic as appropriate.

Example

// Example 1: Modifying a Character Attribute When Entering a Region
// This example demonstrates how a region can be configured to modify a player character's attribute
// when the player enters the region. The RegionApplyCharacterAttributeAction is assigned to the region's action list.

// Assume 'region' is a Region component and 'player' is an IPlayerCharacter instance.
regionAction.Invoke(player, region, false);
// The specified value will be added to the attribute if all conditions are met.

Best Practices

  • Always assign a valid CharacterAttributeTemplate to the attribute field to avoid null reference issues.
  • Use this action for area-based attribute changes, such as healing, damage, or stat boosts.
  • Combine with other region actions for complex region-based gameplay mechanics.
  • Ensure that the player character implements ICharacterAttributeController for attribute modification to succeed.
⚠️ **GitHub.com Fallback** ⚠️