RegionApplyBuffAction - jimdroberts/FishMMO GitHub Wiki

Description

RegionApplyBuffAction is a region action ScriptableObject that applies a specified buff to a player character when triggered within a region. It is used to automatically grant buffs to players entering or interacting with a region, supporting gameplay mechanics such as area-based effects or temporary power-ups.


API Access

Fields

  • public BaseBuffTemplate Buff

    The buff template to apply to the player character when this region action is triggered.

Methods

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

    Invokes the region action, applying the specified buff to the player character if possible. Parameters: - IPlayerCharacter character: The player character to apply the buff to. - 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 BaseBuffTemplate asset exists in your project.
  2. Create a new RegionApplyBuffAction ScriptableObject via the Unity Editor (Assets > Create > FishMMO > Region > Region Apply Buff).
  3. Assign the desired BaseBuffTemplate to the Buff field in the inspector.
  4. Attach the RegionApplyBuffAction to a region's action list or trigger logic as appropriate.

Example

// Example 1: Applying a Buff When Entering a Region
// This example demonstrates how a region can be configured to apply a buff to a player character
// when the player enters the region. The RegionApplyBuffAction 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 buff will be applied to the player if all conditions are met.

Best Practices

  • Always assign a valid BaseBuffTemplate to the Buff field to avoid null reference issues.
  • Use this action for area-based buffs, such as healing zones, damage boosts, or environmental effects.
  • Combine with other region actions for complex region-based gameplay mechanics.
  • Ensure that the player character implements IBuffController for buff application to succeed.
⚠️ **GitHub.com Fallback** ⚠️