RegionApplyBuffAction - jimdroberts/FishMMO GitHub Wiki
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.
-
public BaseBuffTemplate Buff
The buff template to apply to the player character when this region action is triggered.
-
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.
- Ensure a valid
BaseBuffTemplate
asset exists in your project. - Create a new
RegionApplyBuffAction
ScriptableObject via the Unity Editor (Assets > Create > FishMMO > Region > Region Apply Buff). - Assign the desired
BaseBuffTemplate
to theBuff
field in the inspector. - Attach the
RegionApplyBuffAction
to a region's action list or trigger logic as appropriate.
// 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.
- Always assign a valid
BaseBuffTemplate
to theBuff
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.