RegionApplyCharacterAttributeAction - jimdroberts/FishMMO GitHub Wiki
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.
-
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.
-
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.
- Ensure a valid
CharacterAttributeTemplate
asset exists in your project. - Create a new
RegionApplyCharacterAttributeAction
ScriptableObject via the Unity Editor (Assets > Create > FishMMO > Region > Region Apply Character Attribute). - Assign the desired
CharacterAttributeTemplate
to theattribute
field in the inspector. - Set the
value
field to the amount you wish to add to the attribute. - Attach the
RegionApplyCharacterAttributeAction
to a region's action list or trigger logic as appropriate.
// 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.
- Always assign a valid
CharacterAttributeTemplate
to theattribute
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.