Faction - jimdroberts/FishMMO GitHub Wiki

Description

Represents a character's standing or reputation with a specific faction. Holds the current value and a reference to the faction template, clamping the value within valid bounds.


API Access

Fields

  • public int Value

    The current reputation or standing value for this faction. Clamped between FactionTemplate.Minimum and FactionTemplate.Maximum.

Properties

  • public FactionTemplate Template { get; private set; }

    The template defining this faction's properties and relationships.

Methods

  • public Faction(int templateID, int value)

    Constructs a new Faction instance from a template ID and initial value. Looks up the template and clamps the value to valid bounds. templateID (int): The template ID for the faction. value (int): Initial reputation or standing value.


Basic Usage

Setup

  1. Ensure you have valid FactionTemplate assets and their IDs available.
  2. Create a new Faction by providing a template ID and an initial value.
  3. The value will be clamped to the allowed range defined by FactionTemplate.Minimum and FactionTemplate.Maximum.

Example

// Example 1: Creating a Faction instance
int templateID = 1; // ID of the FactionTemplate
int initialValue = 500;
var faction = new Faction(templateID, initialValue);
Debug.Log(faction.Template.Name);
Debug.Log(faction.Value);

// Example 2: Clamping value
var faction = new Faction(templateID, 20000); // Value will be clamped to FactionTemplate.Maximum

Best Practices

  • Always use valid template IDs to ensure the correct FactionTemplate is referenced.
  • Use the Value field to track and update reputation or standing in gameplay systems.
  • Clamp values to the allowed range to prevent logic errors or UI inconsistencies.
⚠️ **GitHub.com Fallback** ⚠️