BaseItemTemplate - jimdroberts/FishMMO GitHub Wiki
Abstract base class for item templates, providing common properties and tooltip logic for all items. Implements ITooltip and ICachedObject for UI and caching support.
-
public bool IsIdentifiable
Indicates if the item can be identified (e.g., has hidden stats).
-
public bool Generate
Indicates if the item should be generated (used in item generation systems).
-
public uint MaxStackSize
The maximum stack size for this item (if greater than 1, item is stackable).
-
public int Price
The price of the item, used for buying/selling.
-
public int[] IconPools
Pools of icons for item generation and randomization.
-
public Sprite icon
The icon sprite representing this item in the UI.
-
public Mesh Mesh
The mesh used for 3D representation of the item.
-
public List Attributes
The base attributes added to the item after generation.
-
public string Name { get; }
Gets the name of this item template (defaults to the asset name).
-
public bool IsStackable { get; }
Returns true if the item is stackable (MaxStackSize > 1).
-
public Sprite Icon { get; }
Gets the icon sprite for this item.
-
public virtual string Tooltip()
Returns the formatted tooltip string for this item, including name and price. Returns: - string: The formatted tooltip string.*
-
public virtual string Tooltip(List combineList)
Returns the formatted tooltip string for this item, optionally combining with other tooltips. Parameters: - List combineList: A list of other tooltips to combine (not used in base implementation). Returns: - string: The formatted tooltip string.*
-
public virtual string GetFormattedDescription()
Returns a formatted description string for the item. Override to provide custom descriptions. Returns: - string: The formatted description string.*
- Inherit from BaseItemTemplate to create custom item templates (e.g., weapons, armor, consumables).
- Set fields such as MaxStackSize, Price, and Attributes as needed for each item type.
- Override Tooltip and GetFormattedDescription for custom UI display.
// Example 1: Creating a custom item template
public class MyItemTemplate : BaseItemTemplate {
// Custom logic or additional fields
}
// Example 2: Accessing item properties
BaseItemTemplate template = ...;
string name = template.Name;
bool stackable = template.IsStackable;
string tooltip = template.Tooltip();
- Use descriptive asset names for each item template for clarity.
- Set MaxStackSize appropriately to control item stacking behavior.
- Override Tooltip and GetFormattedDescription to provide detailed and helpful UI information.
- Document the purpose and configuration of each field in the asset's Inspector description.