Table of Contents

Class ApplyRegionAttributeAction

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

ECA action that changes a character's attribute while it is inside a region. Server-only (gameplay state); suppressed during prediction reconciliation.

[Serializable]
public class ApplyRegionAttributeAction : BaseAction, IAction
Inheritance
ApplyRegionAttributeAction
Implements
Inherited Members

Remarks

Two different operations, chosen by the attribute. A RESOURCE gets a one-shot change to its current value — a drain or a regeneration, safe on OnRegionStay and with nothing to reverse. A non-resource ATTRIBUTE gets a region-owned modifier that lasts while the character is inside and is released when it leaves.

The author does not wire the removal, and that is the point. The contribution is keyed to the region (Region(long, int)) and Region.ReleaseAttributeContributions drops it on every path that ends membership: walking out, a deferred exit flushed after a reconcile or teleport, a descendant region taking ownership, and the region itself despawning. A character that dies or disconnects inside the region raises no exit at all — its whole ledger is cleared by CharacterAttributeController.ResetState on despawn, which is the same guarantee by a different route.

This action used to refuse non-resource attributes outright. Applied through the old AddModifier a region bonus had no owner: nothing reversed it on leaving, dying, disconnecting or changing scene, and on an OnRegionStay trigger it accumulated once per tick forever. Naming the source fixes both — a release is possible, and a restatement every stay tick is idempotent rather than cumulative.

ApplyRegionBuffAction with an AttributeBuffTemplate remains the right choice when the effect should outlive the region — a lingering blessing — or should be dispellable. This action is for a bonus that IS the region.

Fields

Attribute

The attribute to modify. A resource is changed one-shot; anything else is modified for as long as the character is in the region.

[Tooltip("Attribute to modify. A resource gets a one-shot change to its current value; any other attribute gets a region-owned modifier released when the character leaves.")]
public CharacterAttributeTemplate Attribute

Field Value

CharacterAttributeTemplate

EntryIndex

Distinguishes this action's contribution from another action on the SAME region that modifies the SAME attribute.

[Tooltip("Only needed when one region has two of these actions modifying the same attribute. Give them different values so their bonuses sum instead of overwriting each other.")]
public int EntryIndex

Field Value

int

Remarks

Leave it at zero unless a region carries two of these actions pointed at one attribute. CharacterAttribute.SetSource STATES a whole contribution rather than adding to one, so two actions sharing a key are not two contributions — the second silently replaces the first and half the region's bonus disappears with no error anywhere. This is the same hazard Index exists for and that ItemGenerator (keyed by item attribute template) and AttributeBuffTemplate (keyed by list position) already answer; the region action was the one contributor still passing the default.

The release side needs no knowledge of this. Region.ReleaseAttributeContributions goes through ClearSourceGroup, which drops every entry sharing the region's (Kind, Id) whatever index wrote it.

Value

The amount to add to the resource's current value. Negative drains it.

[Tooltip("Amount added to the resource's current value. Negative drains it.")]
public int Value

Field Value

int

Methods

Execute(ICharacter, EventData)

Executes the action. Must be implemented by derived classes.

public override void Execute(ICharacter initiator, EventData eventData)

Parameters

initiator ICharacter

The character initiating the action.

eventData EventData

Event data for the action.