BaseBuffTemplate - jimdroberts/FishMMO GitHub Wiki
Abstract base class for all buff templates, defining shared properties, tooltip logic, and effect hooks. Used as the foundation for all buff types in the FishMMO system.
-
public GameObject FXPrefab
The visual effect prefab to instantiate when the buff is applied.
-
public string Description
The description of the buff, shown in tooltips.
-
private Sprite icon
The icon representing this buff in the UI (serialized field).
-
public float Duration
The duration of the buff in seconds. If 0, the buff may be permanent or event-driven.
-
public float TickRate
The interval in seconds between OnTick calls while the buff is active.
-
public uint UseCount
The number of times this buff can be used or triggered.
-
public uint MaxStacks
The maximum number of stacks this buff can have.
-
public bool IsPermanent
True if the buff is permanent and does not expire.
-
public bool IsDebuff
True if this buff is a debuff (negative effect).
-
public string Name { get; }
The name of this buff template (from the ScriptableObject's name).
-
public Sprite Icon { get; }
The icon for this buff template (from the serialized field).
-
public virtual string Tooltip()
Returns the tooltip string for this buff (primary tooltip only).
-
public virtual string Tooltip(List combineList)
Returns the tooltip string for this buff, optionally combining with other tooltips. combineList (List): Optional list of other tooltips to combine with.
-
public virtual string GetFormattedDescription()
Returns the formatted description for this buff, used in tooltips.
-
public virtual void SecondaryTooltip(Utf16ValueStringBuilder stringBuilder)
Appends additional information to the tooltip (e.g., secondary effects). Override in derived classes. stringBuilder (Utf16ValueStringBuilder): The string builder to append to.
-
public virtual void OnApplyFX(Buff buff, ICharacter target)
Instantiates the FXPrefab on the target when the buff is applied (client-side only). buff (Buff): The buff instance being applied. target (ICharacter): The character receiving the buff.
-
public abstract void OnApply(Buff buff, ICharacter target)
Called when the buff is applied to a character. Must be implemented by derived classes. buff (Buff): The buff instance being applied. target (ICharacter): The character receiving the buff.
-
public abstract void OnRemove(Buff buff, ICharacter target)
Called when the buff is removed from a character. Must be implemented by derived classes. buff (Buff): The buff instance being removed. target (ICharacter): The character losing the buff.
-
public abstract void OnApplyStack(Buff buff, ICharacter target)
Called when a stack of the buff is applied. Must be implemented by derived classes. buff (Buff): The buff instance being stacked. target (ICharacter): The character receiving the stack.
-
public abstract void OnRemoveStack(Buff buff, ICharacter target)
Called when a stack of the buff is removed. Must be implemented by derived classes. buff (Buff): The buff instance being unstacked. target (ICharacter): The character losing the stack.
-
public abstract void OnTick(Buff buff, ICharacter target)
Called on each tick while the buff is active. Must be implemented by derived classes. buff (Buff): The buff instance. target (ICharacter): The character affected.
- Create a new class inheriting from BaseBuffTemplate for each buff type.
- Implement all abstract methods to define buff behavior.
- Assign FXPrefab, Description, Duration, and other fields in the Inspector as needed.
// Example 1: Creating a custom buff template
public class MyBuffTemplate : BaseBuffTemplate {
public override void OnApply(Buff buff, ICharacter target) {
// Custom logic
}
// Implement other abstract methods...
}
// Example 2: Displaying a tooltip
string tooltip = myBuffTemplate.Tooltip();
- Always implement all abstract methods in derived buff templates.
- Use SecondaryTooltip to provide additional information in tooltips.
- Assign FXPrefab and icons for better player feedback.
- Use ScriptableObjects for easy data management and editor integration.