Table of Contents

Class ItemGenerator

Namespace
FishMMO.Shared
Assembly
FishMMO.Shared.dll

Handles random attribute generation and management for items, including applying/removing attributes to characters. Supports equippable and template-based attribute logic, and exposes events for attribute changes.

public class ItemGenerator
Inheritance
ItemGenerator
Inherited Members

Fields

seed

The random seed used for attribute generation.

protected int seed

Field Value

int

Properties

Attributes

Exposes the generated attributes for external access.

public Dictionary<string, ItemAttribute> Attributes { get; }

Property Value

Dictionary<string, ItemAttribute>

Seed

Gets or sets the seed for generation. Changing the seed triggers attribute regeneration.

public int Seed { get; set; }

Property Value

int

Methods

ApplyAttributes(ICharacter)

Applies all generated attributes to the specified character, adding values to their stats/resources.

public void ApplyAttributes(ICharacter character)

Parameters

character ICharacter

The character to apply attributes to.

Remarks

Keyed by the item, so applying twice is applying once. A character loaded from the database, restored from a spawn payload and then corrected by a reconcile can reach this more than once for the same item; under the old accumulate-and-negate shape each arrival doubled the bonus and something downstream had to undo it.

Does nothing for an item with no identity yet — see TryResolveLedgerSource(int, out ModifierSource).

BuildTooltip(TooltipBuilder)

Populates the tooltip builder with generator information and all generated attributes. Uses TooltipColors for consistent formatting.

public void BuildTooltip(TooltipBuilder builder)

Parameters

builder TooltipBuilder

The tooltip builder to populate.

Destroy()

Cleans up the generator, detaching from the item.

public void Destroy()

Generate()

Triggers attribute generation using the current seed and item template.

public void Generate()

Generate(int, BaseItemTemplate)

Generates item attributes using the provided seed and template. Handles equippable logic, random attributes, and additional template attributes.

public void Generate(int seed, BaseItemTemplate template = null)

Parameters

seed int

The random seed for generation.

template BaseItemTemplate

The item template to use. If null, uses the item's template.

GetAttribute(string)

Gets the generated attribute by name, or null if not found.

public ItemAttribute GetAttribute(string name)

Parameters

name string

The attribute name.

Returns

ItemAttribute

The ItemAttribute instance, or null.

Initialize(Item, int)

Initializes the generator with its parent item and seed, triggering attribute generation.

public void Initialize(Item item, int seed)

Parameters

item Item

The item instance.

seed int

The random seed for generation.

RemoveAttributes(ICharacter)

Removes all generated attributes from the specified character, subtracting values from their stats/resources.

public void RemoveAttributes(ICharacter character)

Parameters

character ICharacter

The character to remove attributes from.

SetAttribute(string, int)

Sets the value of a generated attribute by name, and updates the character's attribute modifiers if equipped.

public void SetAttribute(string name, int newValue)

Parameters

name string

The attribute name.

newValue int

The new value to set.