Faction - jimdroberts/FishMMO GitHub Wiki
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.
-
public int Value
The current reputation or standing value for this faction. Clamped between FactionTemplate.Minimum and FactionTemplate.Maximum.
-
public FactionTemplate Template { get; private set; }
The template defining this faction's properties and relationships.
-
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.
- Ensure you have valid FactionTemplate assets and their IDs available.
- Create a new Faction by providing a template ID and an initial value.
- The value will be clamped to the allowed range defined by FactionTemplate.Minimum and FactionTemplate.Maximum.
// 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
- 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.